Hi, thx for replying.
Hum i tried to create a PG, but the PG refuse to load the babylon file from my website
Is there a way to uplaod them with texture in the PG ?
This is my code and a picture.
var canvas = document.getElementById("canvas");
var engine = new BABYLON.Engine(canvas, false, null, false);
var main = new BABYLON.Scene(engine); // global var scene for external function
window.addEventListener('DOMContentLoaded', function(){
if (BABYLON.Engine.isSupported()){
BABYLON.SceneLoader.Load("3d-appart/", "appart.babylon", engine, function (scene) {
main.activeCamera = scene.activeCamera; // to avoid error
//
// ---------------- OPTIMISATION
// Options (target 60fps (which is not possible) with a check every 500ms)
var options = new BABYLON.SceneOptimizerOptions(30, 500);
options.addOptimization(new BABYLON.HardwareScalingOptimization(0, 1));
options.addOptimization(new BABYLON.SceneOptimizerOptions.ModerateDegradationAllowed());
var optimizer = new BABYLON.SceneOptimizer(scene, options); // Optimizer
//scene.debugLayer.show(); // for debuging
// Reducing Shaders Overhead by freezing material (cant change them anymore
var nb = scene.meshes.length;
for (let i = 0; i < nb; i++) {
if( scene.meshes[i].material ){
//scene.meshes[i].material.freeze(); // generate error on console : Reducing shaders checking and updating if matreial are static
}
scene.meshes[i].freezeWorldMatrix(); // Reducing World Matrices Computation ((position / rotation / scaling of a mesh ))
}
// Reducing calls to gl.clear() : stop clearing the color, depth, and stencil buffers before rendering the scene
scene.autoClear = false; // Color buffer
scene.autoClearDepthAndStencil = false; // Depth and stencil, obviously
scene.blockMaterialDirtyMechanism = true; // Blocking the dirty mechanism
scene.cleanCachedTextureBuffer(); // Removing cached texture buffers
engine.doNotHandleContextLost = true; // Turning off support for context lost / contest restore
engine.enableOfflineSupport = false; // Dont require a manifest file
// Freeze active meshes after 10 seconds => issues now, to test
//setTimeout(function(){ scene.freezeActiveMeshes(); }, 5000);
// ---------------- SCENE
var gravtity = new BABYLON.Vector3(0, -.15, 0);
scene.clearColor = new BABYLON.Color3(.6, .8, 1);
scene.ambientColor = new BABYLON.Color3(1,1,0.98);
scene.gravity = new BABYLON.Vector3(0, -.15, 0);
// ---------------- LIGHT
var light = new BABYLON.PointLight("light", new BABYLON.Vector3(5, 5, 1), scene);
light.intensity = 0.7;
// ---------------- CAMERA
var camera = new BABYLON.UniversalCamera('camera', scene.activeCamera.position, scene);
camera.speed = .1; // vitesse deplacement camera
camera.angularSensibility = 3500; // vitesse rotation camera
var postProcess = new BABYLON.FxaaPostProcess("fxaa", 1.0, camera); // anti-alising for more performance
// --- BLENDER SET UP WITH Babylon exporter
camera.checkCollisions = scene.activeCamera.checkCollisions;
camera.applyGravity = scene.activeCamera.applyGravity;
camera.ellipsoid = scene.activeCamera.ellipsoid;
camera.rotation = scene.activeCamera.rotation;
camera.minZ = 0; // min deep of camera view. With 0 and an elipsoid collision system we can avoid to see through/inside meshs.
// --- MOVEMENT
camera.keysUp.push(87); //W
camera.keysDown.push(83); //D
camera.keysLeft.push(65); //A
camera.keysRight.push(68); //S
// apply camera setup to active camera on canvas
scene.activeCamera = camera;
scene.activeCamera.attachControl(canvas, true);
// ---------------- MIRROR
var glass = scene.getMeshByName("o_bathroom_cabinet-mirror");
//Obtain normals for plane and assign one of them as the normal
var glass_vertexData = glass.getVerticesData("normal");
var glassNormal = new BABYLON.Vector3(glass_vertexData[0], glass_vertexData[1], glass_vertexData[2]);
//Create reflecting surface for mirror surface
var reflector = new BABYLON.Plane.FromPositionAndNormal(glass.position, glassNormal.scale(-1));
//Create the mirror material
var mirrorMaterial = new BABYLON.StandardMaterial("mirror", scene);
mirrorMaterial.reflectionTexture = new BABYLON.MirrorTexture("mirror", 1024, scene, true);
mirrorMaterial.reflectionTexture.mirrorPlane = reflector;
mirrorMaterial.reflectionTexture.renderList = [ scene.getMeshByName("o_bathroom_door"), scene.getMeshByName("o_entrance-2_radiator"), scene.getMeshByName("o_baathroom"),
scene.getMeshByName("o_bathroom_shower"), scene.getMeshByName("o_bathroom_shower.001"), scene.getMeshByName("o_bathroom_toilet"),
scene.getMeshByName("o_baathroom_wall-motif.002"),scene.getMeshByName("o_bathroom_ventilation"),scene.getMeshByName("o_bathroom_interruptor.002"),scene.getMeshByName("o_bathroom_interruptor.001"),
scene.getMeshByName("o_bathroom_tap"),scene.getMeshByName("o_baathroom_wall-motif.003"),scene.getMeshByName("o_bathroom_interruptor.003"),
scene.getMeshByName("o_living_walls"),scene.getMeshByName("o_living_plainte"),scene.getMeshByName("o_living.001"),
scene.getMeshByName("o_entrance-2_door"),scene.getMeshByName("o_living_support-wall-light"),scene.getMeshByName("o_living.003")
];
mirrorMaterial.reflectionTexture.level = 0.8;
mirrorMaterial.reflectionTexture.adaptiveBlurKernel = 15;
mirrorMaterial.needDepthPrePass = true; // Using depth pre-pass
glass.material = mirrorMaterial;
light.excludedMeshes.push(scene.getMeshByName("o_living-yellow"), glass);
// ---------------- ACTIONS EVENT
actions(scene);
// ---------------- RENDER
scene.createDefaultEnvironment({
createGround:false
});
// Wait for textures and shaders to be ready
//var fpsLabel = document.getElementById("fpsLabel");
scene.executeWhenReady(function () {
engine.runRenderLoop(function() {
scene.render();
// fpsLabel.innerHTML = engine.getFps().toFixed() + " fps";
});
});
window.addEventListener("resize", function () {
engine.resize();
});
main = scene;
},
// ---------------- LOADING SCREEN
function (evt) {
if (evt.lengthComputable) {
engine.loadingUIText = "<br>Loading, please wait..." + (evt.loaded * 100 / evt.total).toFixed() + "%";}
else {
dlCount = evt.loaded / (1024 * 1024);engine.loadingUIText = "Loading, please wait..." + Math.floor(dlCount * 100.0) / 100.0 + " MB already loaded.";
}
});
}
});