2016-12-01 21:02:00 +01:00
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
function runDemo(canvasId) {
|
|
|
|
|
var canvas = document.getElementById(canvasId);
|
|
|
|
|
var engine = new BABYLON.Engine(canvas, true);
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-01 21:06:23 +01:00
|
|
|
|
// Cr<43>ation de la sc<73>ne
|
2016-12-01 21:02:00 +01:00
|
|
|
|
var scene = new BABYLON.Scene(engine);
|
2016-12-02 02:43:36 +01:00
|
|
|
|
var loader = new BABYLON.AssetsManager(scene);//Obj loader
|
2016-12-02 00:37:38 +01:00
|
|
|
|
BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true;
|
2016-12-01 21:02:00 +01:00
|
|
|
|
scene.gravity = new BABYLON.Vector3(0, -9.81, 0);
|
|
|
|
|
scene.collisionsEnabled = true;
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-01 21:06:23 +01:00
|
|
|
|
// Ajout d'une cam<61>ra et de son contr<74>leur
|
2016-12-01 21:02:00 +01:00
|
|
|
|
var camera = new BABYLON.FreeCamera("MainCamera", new BABYLON.Vector3(0, 2.5, 5), scene);
|
|
|
|
|
camera.applyGravity = true;
|
|
|
|
|
camera.checkCollisions = true;
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-02 03:44:37 +01:00
|
|
|
|
camera.speed = 1;
|
2016-12-01 21:02:00 +01:00
|
|
|
|
camera.angularSensibility = 1000;
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-01 21:02:00 +01:00
|
|
|
|
camera.keysUp = [90]; // Touche Z
|
|
|
|
|
camera.keysDown = [83]; // Touche S
|
|
|
|
|
camera.keysLeft = [81]; // Touche Q
|
|
|
|
|
camera.keysRight = [68]; // Touche D;
|
|
|
|
|
scene.activeCamera.attachControl(canvas);
|
2016-12-01 21:06:23 +01:00
|
|
|
|
|
2016-12-02 00:06:24 +01:00
|
|
|
|
|
2016-12-01 21:06:23 +01:00
|
|
|
|
// Ajout d'une lumi<6D>re
|
2016-12-01 21:02:00 +01:00
|
|
|
|
var light = new BABYLON.PointLight("DirLight", new BABYLON.Vector3(0, 10, 0), scene);
|
|
|
|
|
light.diffuse = new BABYLON.Color3(1, 1, 1);
|
|
|
|
|
light.specular = new BABYLON.Color3(0.6, 0.6, 0.6);
|
2016-12-02 03:44:37 +01:00
|
|
|
|
light.intensity = 1.0;
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-01 22:53:30 +01:00
|
|
|
|
var light2 = new BABYLON.PointLight("DirLight", new BABYLON.Vector3(0, 10, 80), scene);
|
|
|
|
|
light2.diffuse = new BABYLON.Color3(1, 1, 1);
|
|
|
|
|
light2.specular = new BABYLON.Color3(0.6, 0.6, 0.6);
|
2016-12-02 03:44:37 +01:00
|
|
|
|
light2.intensity = 1.0;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
|
2016-12-01 23:15:15 +01:00
|
|
|
|
var light3 = new BABYLON.PointLight("DirLight", new BABYLON.Vector3(0, 10, 160), scene);
|
|
|
|
|
light3.diffuse = new BABYLON.Color3(1, 1, 1);
|
|
|
|
|
light3.specular = new BABYLON.Color3(0.6, 0.6, 0.6);
|
2016-12-02 03:44:37 +01:00
|
|
|
|
light3.intensity = 1.0;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
|
2016-12-01 21:02:00 +01:00
|
|
|
|
// On ajoute une skybox
|
|
|
|
|
createSkybox(scene);
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-01 21:06:23 +01:00
|
|
|
|
// Enfin la sc<73>ne de d<>mo
|
2016-12-01 21:02:00 +01:00
|
|
|
|
createDemoScene(scene);
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-02 00:06:24 +01:00
|
|
|
|
// Creer l obj
|
2016-12-02 00:37:38 +01:00
|
|
|
|
createObj(loader,scene);
|
|
|
|
|
|
|
|
|
|
loader.onFinish = function() {
|
|
|
|
|
engine.runRenderLoop(function () {
|
|
|
|
|
scene.render();
|
|
|
|
|
});
|
|
|
|
|
};
|
2016-12-02 00:06:24 +01:00
|
|
|
|
|
2016-12-02 00:37:38 +01:00
|
|
|
|
loader.load();
|
|
|
|
|
return scene;
|
2016-12-01 21:02:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 00:37:38 +01:00
|
|
|
|
function createObj(loader,scene){
|
2016-12-02 03:10:24 +01:00
|
|
|
|
var stone = new BABYLON.StandardMaterial("stone", scene);
|
|
|
|
|
stone.diffuseTexture = new BABYLON.Texture("images/tileable9.png", scene);
|
2016-12-02 03:31:51 +01:00
|
|
|
|
|
|
|
|
|
var wood = new BABYLON.StandardMaterial("wood", scene);
|
|
|
|
|
wood.diffuseTexture = new BABYLON.Texture("images/wood.jpg", scene);
|
|
|
|
|
|
2016-12-02 03:10:24 +01:00
|
|
|
|
var house = loader.addMeshTask("house1", "", "assets/", "house.obj");
|
2016-12-02 02:43:36 +01:00
|
|
|
|
house.onSuccess = function(t){
|
2016-12-02 01:10:40 +01:00
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
2016-12-02 03:10:24 +01:00
|
|
|
|
m.position.x = -10;
|
|
|
|
|
m.position.y = -5;
|
|
|
|
|
m.position.z = -10;
|
|
|
|
|
m.material = stone;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(3, 3, 3);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
var house2 = loader.addMeshTask("house2", "", "assets/", "house.obj");
|
|
|
|
|
house2.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
|
|
|
|
m.position.y = -5;
|
|
|
|
|
m.material = stone;
|
|
|
|
|
m.position.z = 10;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(3, 3, 3);
|
2016-12-02 01:10:40 +01:00
|
|
|
|
m.checkCollisions = true;
|
2016-12-02 00:37:38 +01:00
|
|
|
|
});
|
|
|
|
|
};
|
2016-12-02 04:17:40 +01:00
|
|
|
|
var f = BABYLON.Mesh.CreateBox("f1", 0.01, scene);
|
|
|
|
|
f.position = new BABYLON.Vector3(5, 0.0, 15);
|
|
|
|
|
createParticle(f,scene);
|
|
|
|
|
var f2 = BABYLON.Mesh.CreateBox("f2", 0.01, scene);
|
|
|
|
|
f2.position = new BABYLON.Vector3(-10, 0.0, -5);
|
|
|
|
|
createParticle(f2,scene);
|
2016-12-02 03:31:51 +01:00
|
|
|
|
|
2016-12-02 03:44:37 +01:00
|
|
|
|
var tent1 = loader.addMeshTask("tent1", "", "assets/", "Tent_1.obj");
|
|
|
|
|
tent1.onSuccess = function(t){
|
2016-12-02 02:58:16 +01:00
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
2016-12-02 03:44:37 +01:00
|
|
|
|
m.position.y = 0;
|
2016-12-02 02:58:16 +01:00
|
|
|
|
m.material = stone;
|
|
|
|
|
m.position.z = 130;
|
|
|
|
|
m.position.x = 10;
|
2016-12-02 03:44:37 +01:00
|
|
|
|
m.scaling = new BABYLON.Vector3(1, 1, 1);
|
2016-12-02 02:58:16 +01:00
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-12-02 03:44:37 +01:00
|
|
|
|
var tent2 = loader.addMeshTask("tent2", "", "assets/", "Tent_1.obj");
|
|
|
|
|
tent2.onSuccess = function(t){
|
2016-12-02 02:58:16 +01:00
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
2016-12-02 03:44:37 +01:00
|
|
|
|
m.position.y = 0;
|
|
|
|
|
m.material = wood;
|
2016-12-02 02:58:16 +01:00
|
|
|
|
m.position.z = 150;
|
|
|
|
|
m.position.x = -10;
|
2016-12-02 03:44:37 +01:00
|
|
|
|
m.rotation.y = Math.PI / 2;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(1, 1, 1);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var tent3 = loader.addMeshTask("tent3", "", "assets/", "Tent_1.obj");
|
|
|
|
|
tent3.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
|
|
|
|
m.position.y = 0;
|
|
|
|
|
m.material = wood;
|
|
|
|
|
m.position.z = 150;
|
|
|
|
|
m.position.x = 5;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(1, 1, 1);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var tent4 = loader.addMeshTask("tent4", "", "assets/", "Tent_1.obj");
|
|
|
|
|
tent4.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
|
|
|
|
m.position.y = 0;
|
|
|
|
|
m.material = wood;
|
|
|
|
|
m.position.z = 130;
|
|
|
|
|
m.position.x = -10;
|
|
|
|
|
m.rotation.y = Math.PI / 2;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(1, 1, 1);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-12-02 03:57:30 +01:00
|
|
|
|
var noye1 = loader.addMeshTask("noye1", "", "assets/", "generic_male_02.obj");
|
2016-12-02 03:44:37 +01:00
|
|
|
|
noye1.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
2016-12-02 03:57:30 +01:00
|
|
|
|
m.position.y = -3;
|
2016-12-02 03:44:37 +01:00
|
|
|
|
m.position.z = 70;
|
2016-12-02 03:57:30 +01:00
|
|
|
|
m.position.x = 1;
|
|
|
|
|
m.rotation.y = Math.PI / 2;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(1, 1, 1);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var noye2 = loader.addMeshTask("noye2", "", "assets/", "generic_male_02.obj");
|
|
|
|
|
noye2.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
|
|
|
|
m.position.y = -3;
|
|
|
|
|
m.position.z = 60;
|
|
|
|
|
m.position.x = 5;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(1, 1, 1);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var migrant1 = loader.addMeshTask("migrant1", "", "assets/", "generic_male_02.obj");
|
|
|
|
|
migrant1.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
|
|
|
|
m.position.y = 0;
|
|
|
|
|
m.position.z = 130;
|
|
|
|
|
m.position.x = 1;
|
2016-12-02 03:44:37 +01:00
|
|
|
|
m.rotation.y = Math.PI / 2;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(1, 1, 1);
|
2016-12-02 02:58:16 +01:00
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-12-02 03:57:30 +01:00
|
|
|
|
var migrant2 = loader.addMeshTask("migrant2", "", "assets/", "generic_male_02.obj");
|
|
|
|
|
migrant2.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 10;
|
|
|
|
|
m.position.y = 0;
|
|
|
|
|
m.position.z = 135;
|
|
|
|
|
m.position.x = 5;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(1, 1, 1);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-12-02 03:31:51 +01:00
|
|
|
|
var boat1 = loader.addMeshTask("boat1", "", "assets/", "Cannoe.obj");
|
|
|
|
|
boat1.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 0;
|
|
|
|
|
m.position.y = -11;
|
|
|
|
|
m.material = wood;
|
|
|
|
|
m.position.z = 60;
|
|
|
|
|
m.rotation.z = Math.PI/16;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(3, 3, 3);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
2016-12-02 02:35:56 +01:00
|
|
|
|
|
|
|
|
|
var boat2 = loader.addMeshTask("boat1", "", "assets/", "Cannoe.obj");
|
|
|
|
|
boat2.onSuccess = function(t){
|
|
|
|
|
t.loadedMeshes.forEach(function(m) {//m = model
|
|
|
|
|
m.position.x = 0;
|
|
|
|
|
m.position.y = -11;
|
|
|
|
|
m.position.x = -10;
|
|
|
|
|
m.material = wood;
|
|
|
|
|
m.position.z = 80;
|
|
|
|
|
m.rotation.z = Math.PI/16;
|
|
|
|
|
m.rotation.y = Math.PI / 2;
|
|
|
|
|
m.scaling = new BABYLON.Vector3(3, 3, 3);
|
|
|
|
|
m.checkCollisions = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
2016-12-02 02:43:36 +01:00
|
|
|
|
// BABYLON.SceneLoader.ImportMesh("test", "assets/", "house.babylon", scene, function (newMeshes){
|
|
|
|
|
// modele = newMeshes;
|
|
|
|
|
// modele.rotation.x = 10;
|
|
|
|
|
// });
|
2016-12-02 00:37:38 +01:00
|
|
|
|
}
|
2016-12-02 00:06:24 +01:00
|
|
|
|
|
2016-12-01 21:02:00 +01:00
|
|
|
|
function createSkybox(scene) {
|
2016-12-01 21:06:23 +01:00
|
|
|
|
// Cr<43>ation d'une material
|
2016-12-01 21:02:00 +01:00
|
|
|
|
var sMaterial = new BABYLON.StandardMaterial("skyboxMaterial", scene);
|
|
|
|
|
sMaterial.backFaceCulling = false;
|
|
|
|
|
sMaterial.reflectionTexture = new BABYLON.CubeTexture("images/skybox/skybox", scene);
|
|
|
|
|
sMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-01 21:06:23 +01:00
|
|
|
|
// Cr<43>ation d'un cube avec la material adapt<70>e
|
2016-12-01 23:15:15 +01:00
|
|
|
|
var skybox = BABYLON.Mesh.CreateBox("skybox", 400, scene);
|
2016-12-01 21:02:00 +01:00
|
|
|
|
skybox.material = sMaterial;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 04:17:40 +01:00
|
|
|
|
function createParticle(object,scene){
|
|
|
|
|
//Smoke
|
|
|
|
|
var smokeSystem = new BABYLON.ParticleSystem("particles", 2000, scene);
|
|
|
|
|
smokeSystem.particleTexture = new BABYLON.Texture("images/flare.png", scene);
|
|
|
|
|
smokeSystem.emitter = object; // the starting object, the emitter
|
|
|
|
|
smokeSystem.minEmitBox = new BABYLON.Vector3(-1, 1, -1); // Starting all from
|
|
|
|
|
smokeSystem.maxEmitBox = new BABYLON.Vector3(1, 1, 1); // To...
|
2016-12-02 00:06:24 +01:00
|
|
|
|
|
2016-12-02 04:17:40 +01:00
|
|
|
|
smokeSystem.color1 = new BABYLON.Color4(0.1, 0.1, 0.1, 1.0);
|
|
|
|
|
smokeSystem.color2 = new BABYLON.Color4(0.1, 0.1, 0.1, 1.0);
|
|
|
|
|
smokeSystem.colorDead = new BABYLON.Color4(0, 0, 0, 0.0);
|
|
|
|
|
|
|
|
|
|
smokeSystem.minSize = 0.5;
|
|
|
|
|
smokeSystem.maxSize = 2;
|
|
|
|
|
|
|
|
|
|
smokeSystem.minLifeTime = 0.3;
|
|
|
|
|
smokeSystem.maxLifeTime = 1.5;
|
|
|
|
|
|
|
|
|
|
smokeSystem.emitRate = 500;
|
|
|
|
|
|
|
|
|
|
// Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
|
|
|
|
|
smokeSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
|
|
|
|
|
|
|
|
|
|
smokeSystem.gravity = new BABYLON.Vector3(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
smokeSystem.direction1 = new BABYLON.Vector3(0, 8, 0);
|
|
|
|
|
smokeSystem.direction2 = new BABYLON.Vector3(0, 8, 0);
|
|
|
|
|
|
|
|
|
|
smokeSystem.minAngularSpeed = 0;
|
|
|
|
|
smokeSystem.maxAngularSpeed = Math.PI;
|
|
|
|
|
|
|
|
|
|
smokeSystem.minEmitPower = 1;
|
|
|
|
|
smokeSystem.maxEmitPower = 2;
|
|
|
|
|
smokeSystem.updateSpeed = 0.005;
|
|
|
|
|
|
|
|
|
|
smokeSystem.start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create a particle system
|
|
|
|
|
var fireSystem = new BABYLON.ParticleSystem("particles", 2000, scene);
|
|
|
|
|
|
|
|
|
|
//Texture of each particle
|
|
|
|
|
fireSystem.particleTexture = new BABYLON.Texture("images/flare.png", scene);
|
|
|
|
|
|
|
|
|
|
// Where the particles come from
|
|
|
|
|
fireSystem.emitter = object; // the starting object, the emitter
|
|
|
|
|
fireSystem.minEmitBox = new BABYLON.Vector3(-0.5, 1, -0.5); // Starting all from
|
|
|
|
|
fireSystem.maxEmitBox = new BABYLON.Vector3(0.5, 1, 0.5); // To...
|
|
|
|
|
|
|
|
|
|
// Colors of all particles
|
|
|
|
|
fireSystem.color1 = new BABYLON.Color4(1, 0.5, 0, 1.0);
|
|
|
|
|
fireSystem.color2 = new BABYLON.Color4(1, 0.5, 0, 1.0);
|
|
|
|
|
fireSystem.colorDead = new BABYLON.Color4(0, 0, 0, 0.0);
|
|
|
|
|
|
|
|
|
|
// Size of each particle (random between...
|
|
|
|
|
fireSystem.minSize = 0.5;
|
|
|
|
|
fireSystem.maxSize = 1;
|
|
|
|
|
|
|
|
|
|
// Life time of each particle (random between...
|
|
|
|
|
fireSystem.minLifeTime = 0.2;
|
|
|
|
|
fireSystem.maxLifeTime = 0.4;
|
|
|
|
|
|
|
|
|
|
// Emission rate
|
|
|
|
|
fireSystem.emitRate = 500;
|
|
|
|
|
|
|
|
|
|
// Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
|
|
|
|
|
fireSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
|
|
|
|
|
|
|
|
|
|
// Set the gravity of all particles
|
|
|
|
|
fireSystem.gravity = new BABYLON.Vector3(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
// Direction of each particle after it has been emitted
|
|
|
|
|
fireSystem.direction1 = new BABYLON.Vector3(0, 8, 0);
|
|
|
|
|
fireSystem.direction2 = new BABYLON.Vector3(0, 8, 0);
|
|
|
|
|
|
|
|
|
|
// Angular speed, in radians
|
|
|
|
|
fireSystem.minAngularSpeed = 0;
|
|
|
|
|
fireSystem.maxAngularSpeed = Math.PI;
|
|
|
|
|
|
|
|
|
|
// Speed
|
|
|
|
|
fireSystem.minEmitPower = 1;
|
|
|
|
|
fireSystem.maxEmitPower = 3;
|
|
|
|
|
fireSystem.updateSpeed = 0.005;
|
|
|
|
|
|
|
|
|
|
// Start the particle system
|
|
|
|
|
fireSystem.start();
|
|
|
|
|
}
|
2016-12-02 00:06:24 +01:00
|
|
|
|
|
2016-12-01 21:02:00 +01:00
|
|
|
|
function createDemoScene(scene) {
|
2016-12-02 01:27:38 +01:00
|
|
|
|
|
2016-12-01 21:06:23 +01:00
|
|
|
|
// Cr<43>ation d'un sol
|
2016-12-02 00:07:56 +01:00
|
|
|
|
|
2016-12-02 01:11:29 +01:00
|
|
|
|
var groundMaterial = new BABYLON.StandardMaterial("groundMaterial", scene);
|
|
|
|
|
groundMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
var groundMaterial1 = new BABYLON.StandardMaterial("groundMaterial1", scene);
|
|
|
|
|
groundMaterial1.diffuseTexture = new BABYLON.Texture("images/groundSable.png", scene);
|
|
|
|
|
groundMaterial1.diffuseTexture.uScale = 6;
|
|
|
|
|
groundMaterial1.diffuseTexture.vScale = 6;
|
|
|
|
|
groundMaterial1.specularColor = new BABYLON.Color3(0, 0, 0);
|
2016-12-02 00:07:56 +01:00
|
|
|
|
|
2016-12-02 02:09:42 +01:00
|
|
|
|
var wall = new BABYLON.StandardMaterial("wall", scene);
|
|
|
|
|
wall.diffuseTexture = new BABYLON.Texture("images/skybox/skybox_nx.jpg", scene);
|
|
|
|
|
wall.diffuseTexture.uScale = 1;
|
|
|
|
|
wall.diffuseTexture.vScale = 1;
|
|
|
|
|
wall.specularColor = new BABYLON.Color3(0, 0, 0);
|
|
|
|
|
|
2016-12-02 00:06:24 +01:00
|
|
|
|
var ground = BABYLON.Mesh.CreatePlane("ground", 50, scene);
|
|
|
|
|
ground.rotation.x = Math.PI / 2;
|
|
|
|
|
ground.material = new BABYLON.StandardMaterial("gMaterial", scene);
|
2016-12-02 01:11:29 +01:00
|
|
|
|
ground.material = groundMaterial1;
|
2016-12-02 00:06:24 +01:00
|
|
|
|
ground.checkCollisions = true;
|
|
|
|
|
|
2016-12-02 04:19:13 +01:00
|
|
|
|
var textSalle1 = new BABYLON.StandardMaterial("texture4", scene);
|
|
|
|
|
textSalle1.diffuseTexture = new BABYLON.Texture("images/text.png", scene);
|
|
|
|
|
textSalle1.specularColor = new BABYLON.Color3(0, 0, 0);
|
|
|
|
|
|
2016-12-02 00:06:24 +01:00
|
|
|
|
var mur1 = BABYLON.Mesh.CreatePlane("mur1", 50, scene);
|
|
|
|
|
mur1.rotation.y = Math.PI / 2;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur1.position.y = -15;
|
2016-12-02 00:06:24 +01:00
|
|
|
|
mur1.position.x = 25;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur1.visibility = 1;
|
2016-12-02 04:19:13 +01:00
|
|
|
|
mur1.material = textSalle1;
|
2016-12-02 00:06:24 +01:00
|
|
|
|
mur1.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur2 = BABYLON.Mesh.CreatePlane("mur2", 50, scene);
|
|
|
|
|
mur2.rotation.y = -(Math.PI / 2);
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur2.position.y = -15;
|
2016-12-02 00:06:24 +01:00
|
|
|
|
mur2.position.x = -25;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur2.visibility = 1;
|
|
|
|
|
mur2.material = wall;
|
2016-12-02 00:06:24 +01:00
|
|
|
|
mur2.checkCollisions = true;
|
|
|
|
|
|
2016-12-01 23:48:40 +01:00
|
|
|
|
var mur31Salle1 = BABYLON.Mesh.CreatePlane("mur31Salle1", 20, scene);
|
|
|
|
|
mur31Salle1.rotation.z = Math.PI / 2;
|
|
|
|
|
mur31Salle1.position.z = 25;
|
|
|
|
|
mur31Salle1.position.x = -15;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur31Salle1.visibility = 1;
|
|
|
|
|
mur31Salle1.material = wall;
|
2016-12-01 23:48:40 +01:00
|
|
|
|
mur31Salle1.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur32Salle1 = BABYLON.Mesh.CreatePlane("mur32Salle1", 20, scene);
|
|
|
|
|
mur32Salle1.rotation.z = Math.PI / 2;
|
|
|
|
|
mur32Salle1.position.z = 25;
|
|
|
|
|
mur32Salle1.position.x = 15;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur32Salle1.visibility = 1;
|
|
|
|
|
mur32Salle1.material = wall;
|
2016-12-01 23:48:40 +01:00
|
|
|
|
mur32Salle1.checkCollisions = true;
|
2016-12-02 00:06:24 +01:00
|
|
|
|
|
|
|
|
|
var mur4 = BABYLON.Mesh.CreatePlane("mur4", 50, scene);
|
|
|
|
|
mur4.rotation.x = Math.PI;
|
|
|
|
|
mur4.position.z = -25;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur4.position.y = -15;
|
|
|
|
|
mur4.visibility = 1;
|
|
|
|
|
mur4.material = wall;
|
2016-12-02 00:06:24 +01:00
|
|
|
|
mur4.checkCollisions = true;
|
2016-12-01 22:31:33 +01:00
|
|
|
|
|
2016-12-01 23:48:40 +01:00
|
|
|
|
/*--------------COULOIR 1--------------------*/
|
|
|
|
|
|
2016-12-02 00:30:35 +01:00
|
|
|
|
var textCouloir1 = new BABYLON.StandardMaterial("texture3", scene);
|
|
|
|
|
textCouloir1.diffuseTexture = new BABYLON.Texture("images/textCouloir1.png", scene);
|
2016-12-02 00:44:24 +01:00
|
|
|
|
textCouloir1.specularColor = new BABYLON.Color3(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
var textCouloir11 = new BABYLON.StandardMaterial("texture4", scene);
|
|
|
|
|
textCouloir11.diffuseTexture = new BABYLON.Texture("images/noir.png", scene);
|
|
|
|
|
textCouloir11.specularColor = new BABYLON.Color3(0, 0, 0);
|
2016-12-02 00:30:35 +01:00
|
|
|
|
|
2016-12-01 23:48:40 +01:00
|
|
|
|
var groundCouloir1 = BABYLON.Mesh.CreateGround("groundCouloir1", 10, 20, 2, scene);
|
|
|
|
|
groundCouloir1.material = new BABYLON.StandardMaterial("gMaterial", scene);
|
2016-12-02 00:07:56 +01:00
|
|
|
|
groundCouloir1.material = groundMaterial;
|
2016-12-01 23:48:40 +01:00
|
|
|
|
groundCouloir1.position.z = 35;
|
|
|
|
|
groundCouloir1.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur1Couloir1 = BABYLON.Mesh.CreatePlane("mur1Couloir1", 20, scene);
|
2016-12-02 00:30:35 +01:00
|
|
|
|
mur1Couloir1.material = textCouloir1;
|
2016-12-01 23:48:40 +01:00
|
|
|
|
mur1Couloir1.rotation.y = Math.PI / 2;
|
|
|
|
|
mur1Couloir1.position.z = 35;
|
|
|
|
|
mur1Couloir1.position.x = 5;
|
2016-12-02 00:30:35 +01:00
|
|
|
|
mur1Couloir1.visibility = 1;
|
2016-12-01 23:48:40 +01:00
|
|
|
|
mur1Couloir1.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur2Couloir1 = BABYLON.Mesh.CreatePlane("mur2Couloir1", 20, scene);
|
2016-12-02 00:44:24 +01:00
|
|
|
|
mur2Couloir1.material = textCouloir11;
|
2016-12-01 23:48:40 +01:00
|
|
|
|
mur2Couloir1.rotation.y = -(Math.PI / 2);
|
|
|
|
|
mur2Couloir1.position.z = 35;
|
|
|
|
|
mur2Couloir1.position.x = -5;
|
2016-12-02 00:44:24 +01:00
|
|
|
|
mur2Couloir1.visibility = 1;
|
2016-12-01 23:48:40 +01:00
|
|
|
|
mur2Couloir1.checkCollisions = true;
|
|
|
|
|
|
2016-12-01 22:53:30 +01:00
|
|
|
|
/*-----------------SALLE 2----------------------------------*/
|
|
|
|
|
|
2016-12-02 01:11:29 +01:00
|
|
|
|
var groundMaterial2 = new BABYLON.StandardMaterial("groundMaterial2", scene);
|
|
|
|
|
groundMaterial2.diffuseTexture = new BABYLON.Texture("images/groundEau.jpg", scene);
|
|
|
|
|
groundMaterial2.diffuseTexture.uScale = 6;
|
|
|
|
|
groundMaterial2.diffuseTexture.vScale = 6;
|
|
|
|
|
groundMaterial2.specularColor = new BABYLON.Color3(0, 0, 0);
|
|
|
|
|
|
2016-12-01 22:53:30 +01:00
|
|
|
|
var groundSalle2 = BABYLON.Mesh.CreatePlane("groundSalle2", 50, scene);
|
|
|
|
|
groundSalle2.rotation.x = Math.PI / 2;
|
|
|
|
|
groundSalle2.position.z = 70;
|
|
|
|
|
groundSalle2.material = new BABYLON.StandardMaterial("gMaterial", scene);
|
2016-12-02 01:11:29 +01:00
|
|
|
|
groundSalle2.material = groundMaterial2;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
groundSalle2.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur11Salle2 = BABYLON.Mesh.CreatePlane("mur11Salle2", 20, scene);
|
|
|
|
|
mur11Salle2.rotation.x = Math.PI;
|
|
|
|
|
mur11Salle2.position.z = 45;
|
|
|
|
|
mur11Salle2.position.x = 15;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur11Salle2.visibility = 1;
|
|
|
|
|
mur11Salle2.material = wall;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
mur11Salle2.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur12Salle2 = BABYLON.Mesh.CreatePlane("mur12Salle2", 20, scene);
|
|
|
|
|
mur12Salle2.rotation.x = Math.PI;
|
|
|
|
|
mur12Salle2.position.z = 45;
|
|
|
|
|
mur12Salle2.position.x = -15;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur12Salle2.visibility = 1;
|
|
|
|
|
mur12Salle2.material = wall;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
mur12Salle2.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur2Salle2 = BABYLON.Mesh.CreatePlane("mur2Salle2", 50, scene);
|
|
|
|
|
mur2Salle2.rotation.y = -(Math.PI / 2);
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur2Salle2.position.y = -15;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
mur2Salle2.position.x = -25;
|
|
|
|
|
mur2Salle2.position.z = 70;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur2Salle2.visibility = 1;
|
|
|
|
|
mur2Salle2.material = wall;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
mur2Salle2.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur31Salle1 = BABYLON.Mesh.CreatePlane("mur31Salle1", 20, scene);
|
|
|
|
|
mur31Salle1.rotation.z = Math.PI / 2;
|
|
|
|
|
mur31Salle1.position.z = 95;
|
|
|
|
|
mur31Salle1.position.x = -15;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur31Salle1.visibility = 1;
|
|
|
|
|
mur31Salle1.material = wall;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
mur31Salle1.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur32Salle1 = BABYLON.Mesh.CreatePlane("mur32Salle1", 20, scene);
|
|
|
|
|
mur32Salle1.rotation.z = Math.PI / 2;
|
|
|
|
|
mur32Salle1.position.z = 95;
|
|
|
|
|
mur32Salle1.position.x = 15;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur32Salle1.visibility = 1;
|
|
|
|
|
mur32Salle1.material = wall;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
mur32Salle1.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur4Salle2 = BABYLON.Mesh.CreatePlane("mur4Salle2", 50, scene);
|
|
|
|
|
mur4Salle2.rotation.y = Math.PI / 2;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur4Salle2.position.y = -15;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
mur4Salle2.position.x = 25;
|
|
|
|
|
mur4Salle2.position.z = 70;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur4Salle2.visibility = 1;
|
|
|
|
|
mur4Salle2.material = wall;
|
2016-12-01 22:53:30 +01:00
|
|
|
|
mur4Salle2.checkCollisions = true;
|
|
|
|
|
|
2016-12-01 23:15:15 +01:00
|
|
|
|
/*--------------COULOIR 2--------------------*/
|
|
|
|
|
|
2016-12-02 00:44:24 +01:00
|
|
|
|
var textCouloir2 = new BABYLON.StandardMaterial("texture5", scene);
|
|
|
|
|
textCouloir2.diffuseTexture = new BABYLON.Texture("images/textCouloir2.png", scene);
|
|
|
|
|
textCouloir2.specularColor = new BABYLON.Color3(0, 0, 0);
|
|
|
|
|
|
2016-12-01 23:15:15 +01:00
|
|
|
|
var groundCouloir2 = BABYLON.Mesh.CreateGround("groundCouloir2", 10, 20, 2, scene);
|
|
|
|
|
groundCouloir2.material = new BABYLON.StandardMaterial("gMaterial", scene);
|
2016-12-02 00:07:56 +01:00
|
|
|
|
groundCouloir2.material = groundMaterial;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
groundCouloir2.position.z = 105;
|
|
|
|
|
groundCouloir2.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur1Couloir2 = BABYLON.Mesh.CreatePlane("mur1Couloir2", 20, scene);
|
|
|
|
|
mur1Couloir2.rotation.y = Math.PI / 2;
|
|
|
|
|
mur1Couloir2.position.z = 105;
|
|
|
|
|
mur1Couloir2.position.x = 5;
|
2016-12-02 00:44:24 +01:00
|
|
|
|
mur1Couloir2.visibility = 1;
|
|
|
|
|
mur1Couloir2.material = textCouloir2;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur1Couloir2.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur2Couloir2 = BABYLON.Mesh.CreatePlane("mur2Couloir2", 20, scene);
|
|
|
|
|
mur2Couloir2.rotation.y = -(Math.PI / 2);
|
|
|
|
|
mur2Couloir2.position.z = 105;
|
|
|
|
|
mur2Couloir2.position.x = -5;
|
2016-12-02 00:44:24 +01:00
|
|
|
|
mur2Couloir2.visibility = 1;
|
|
|
|
|
mur2Couloir2.material = textCouloir11;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur2Couloir2.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
/*----------------SALLE 3-------------------------*/
|
|
|
|
|
|
2016-12-02 01:11:29 +01:00
|
|
|
|
var groundMaterial3 = new BABYLON.StandardMaterial("groundMaterial3", scene);
|
|
|
|
|
groundMaterial3.diffuseTexture = new BABYLON.Texture("images/groundTerre.png", scene);
|
|
|
|
|
groundMaterial3.diffuseTexture.uScale = 6;
|
|
|
|
|
groundMaterial3.diffuseTexture.vScale = 6;
|
|
|
|
|
groundMaterial3.specularColor = new BABYLON.Color3(0, 0, 0);
|
|
|
|
|
|
2016-12-01 23:15:15 +01:00
|
|
|
|
var groundSalle3 = BABYLON.Mesh.CreatePlane("groundSalle3", 50, scene);
|
|
|
|
|
groundSalle3.rotation.x = Math.PI / 2;
|
|
|
|
|
groundSalle3.position.z = 140;
|
|
|
|
|
groundSalle3.material = new BABYLON.StandardMaterial("gMaterial", scene);
|
2016-12-02 01:11:29 +01:00
|
|
|
|
groundSalle3.material = groundMaterial3;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
groundSalle3.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur11Salle3 = BABYLON.Mesh.CreatePlane("mur11Salle3", 20, scene);
|
|
|
|
|
mur11Salle3.rotation.x = Math.PI;
|
|
|
|
|
mur11Salle3.position.z = 115;
|
|
|
|
|
mur11Salle3.position.x = 15;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur11Salle3.visibility = 1;
|
|
|
|
|
mur11Salle3.material = wall;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur11Salle3.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur12Salle3 = BABYLON.Mesh.CreatePlane("mur12Salle3", 20, scene);
|
|
|
|
|
mur12Salle3.rotation.x = Math.PI;
|
|
|
|
|
mur12Salle3.position.z = 115;
|
|
|
|
|
mur12Salle3.position.x = -15;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur12Salle3.visibility = 1;
|
|
|
|
|
mur12Salle3.material = wall;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur12Salle3.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur2Salle3 = BABYLON.Mesh.CreatePlane("mur2Salle3", 50, scene);
|
|
|
|
|
mur2Salle3.rotation.y = -(Math.PI / 2);
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur2Salle3.position.y = -15;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur2Salle3.position.x = -25;
|
|
|
|
|
mur2Salle3.position.z = 140;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur2Salle3.visibility = 1;
|
|
|
|
|
mur2Salle3.material = wall;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur2Salle3.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur31Salle3 = BABYLON.Mesh.CreatePlane("mur31Salle3", 50, scene);
|
|
|
|
|
mur31Salle3.rotation.z = Math.PI / 2;
|
|
|
|
|
mur31Salle3.position.z = 165;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur31Salle3.position.y = -15;
|
|
|
|
|
mur31Salle3.visibility = 1;
|
|
|
|
|
mur31Salle3.material = wall;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur31Salle3.checkCollisions = true;
|
|
|
|
|
|
|
|
|
|
var mur4Salle3 = BABYLON.Mesh.CreatePlane("mur4Salle3", 50, scene);
|
|
|
|
|
mur4Salle3.rotation.y = Math.PI / 2;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur4Salle3.position.y = -15;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur4Salle3.position.x = 25;
|
|
|
|
|
mur4Salle3.position.z = 140;
|
2016-12-02 02:09:42 +01:00
|
|
|
|
mur4Salle3.visibility = 1;
|
|
|
|
|
mur4Salle3.material = wall;
|
2016-12-01 23:15:15 +01:00
|
|
|
|
mur4Salle3.checkCollisions = true;
|
|
|
|
|
|
2016-12-02 04:39:57 +01:00
|
|
|
|
|
2016-12-02 02:58:16 +01:00
|
|
|
|
var box = new BABYLON.Mesh.CreateBox("crate", 2, scene);
|
|
|
|
|
box.material = new BABYLON.StandardMaterial("Mat", scene);
|
|
|
|
|
box.material.diffuseTexture = new BABYLON.Texture("images/box.png", scene);
|
|
|
|
|
box.position = new BABYLON.Vector3(20, 1, 140);
|
|
|
|
|
|
|
|
|
|
var box3 = new BABYLON.Mesh.CreateBox("crate", 2, scene);
|
|
|
|
|
box3.material = new BABYLON.StandardMaterial("Mat", scene);
|
|
|
|
|
box3.material.diffuseTexture = new BABYLON.Texture("images/box.png", scene);
|
|
|
|
|
box3.material.diffuseTexture.hasAlpha = true;
|
|
|
|
|
box3.position = new BABYLON.Vector3(20, 1, 130);
|
|
|
|
|
|
|
|
|
|
var box4 = new BABYLON.Mesh.CreateBox("crate", 2, scene);
|
|
|
|
|
box4.material = new BABYLON.StandardMaterial("Mat", scene);
|
|
|
|
|
box4.material.diffuseTexture = new BABYLON.Texture("images/box.png", scene);
|
|
|
|
|
box4.material.diffuseTexture.hasAlpha = true;
|
2016-12-02 03:44:37 +01:00
|
|
|
|
box4.position = new BABYLON.Vector3(-15, 1, 145);
|
2016-12-02 02:58:16 +01:00
|
|
|
|
|
|
|
|
|
var box5 = new BABYLON.Mesh.CreateBox("crate", 2, scene);
|
|
|
|
|
box5.material = new BABYLON.StandardMaterial("Mat", scene);
|
|
|
|
|
box5.material.diffuseTexture = new BABYLON.Texture("images/box.png", scene);
|
|
|
|
|
box5.material.diffuseTexture.hasAlpha = true;
|
|
|
|
|
box5.position = new BABYLON.Vector3(-30, 1, 150);
|
|
|
|
|
|
|
|
|
|
var box6 = new BABYLON.Mesh.CreateBox("crate", 2, scene);
|
|
|
|
|
box6.material = new BABYLON.StandardMaterial("Mat", scene);
|
|
|
|
|
box6.material.diffuseTexture = new BABYLON.Texture("images/box.png", scene);
|
|
|
|
|
box6.position = new BABYLON.Vector3(0, 1, 120);
|
2016-12-01 22:31:33 +01:00
|
|
|
|
}
|