deni

Members
  • Content Count

    8
  • Joined

  • Last visited

  1. I've tried the next code and it works ( I've tried to load file using readAsDataURL() from the FileReader object ): function handleFiles( event ) { var uploader = event.srcElement || event.currentTarget; var files = uploader.files; var reader = new FileReader(); reader.onload = function( event ) { var result = event.target.result; BABYLON.SceneLoader.ImportMesh( null, event.target.result, '', scene, function( newMeshes, particleSystems, skeletons ) { var mesh = newMeshes[ 0 ]; mesh.position = new BABYLON.Vector3( 0, 0, 0 ); } ); }; reader.readAsDataURL( files[ 0 ] ); }The result is: The building with some blue colors in scene ( it's texture, ugly, but it doesn't make sense right now ). Also there is an error in console: GET data:;base64,eyJhdXRvQ2xlYXIiOnRydWUsImNsZWFyQ29sb3IiOlswLDAsMF0sImFtYmllbn…iI6WzEsMSwxXX1dLA0KInNoYWRvd0dlbmVyYXRvcnMiOltdfQ==.manifest?1441026249629 net::ERR_INVALID_URLWe can see, that BJS is also trying to fetch a *.manifest file. So, the problem is rather solved, but guys how can I disable tries to load the *.manifest files in BJS runtime?
  2. Thanks for the good sample link. Now I'm viewing the source of it. I've found that for the same functionality there are such possibilities in BabylonJs: var filesInput = new BABYLON.FilesInput( engine, null, canvas, null );filesInput.monitorElementForDragNDrop( canvas );var htmlInput = document.getElementById( 'uploader' );htmlInput.addEventListener( 'change', function( event ) { filesInput.loadFiles( event );}, false );I've tried it, but there is some bad stuff. The scene is disposing and inserting the new model into it, if to view the source of the prototype which is mentioned above: FilesInput.prototype.reload = function () { var _this = this; var that = this; // If a ".babylon" file has been provided if (this._sceneFileToLoad) { if (this._currentScene) { this._engine.stopRenderLoop(); this._currentScene.dispose(); } BABYLON.SceneLoader.Load("file:", this._sceneFileToLoad, this._engine, function (newScene) { .....But I want just to paste a new *.babylon model to the existed scene with already added previously meshes.Of course, I shall learn the source code more deeply... But, maybe you have the source code/sample which solves my problem in more easy way?
  3. Don't understand at all what you have said. Inline textures? What is it? Latency? I may upload it from localhost using File API and then register to scene. So what latency? Don't understand you reply at all.
  4. What's about right now? Has such possibilities appeared in BabylonJs?
  5. I'm pretty fine working with the .babylon file format. Exporter which was developed for Blender 3D editor works perfectly and if to load the exported model using the next code: // won't write the full code// because it was fetched from the playground and it's very standard and worksBABYLON.SceneLoader.Load("", "fileName.babylon", engine, function (newScene) {...works well and WebGL renderer in browser shows my model. But, what if I don't want to load models as static files which must be saved in public folder of HTTP-server ( IIS, Apache, lighttpd, nginx, etc.. ). For e.g. I wanna load a .babylon file from the user's side or to secure the access to .babylon files at my backend. All right, let's watch the situation, if I provide some kind of Uploader (using File API from browser) in my web-application, from which user will be able to load 3D-models from their PC or other devices. I'm trying to load models like this way: File uploading ( change event of input-file ) which works well: function handleFiles( event ) { var uploader = event.srcElement || event.currentTarget; var files = uploader.files; var reader = new FileReader(); reader.onload = function( event ) { var data = JSON.parse( event.target.result ); loadCustomMesh( data ); }; // passing only single mesh because of testing purpose reader.readAsText( files[ 0 ] ); }Handling geometry and adding to scene: function loadCustomMesh( data ) { var mesh = new BABYLON.Mesh( Math.random().toString(), scene ); mesh.setVerticesData( BABYLON.VertexBuffer.PositionKind, data.meshes[ 0 ].positions, true ); mesh.setVerticesData( BABYLON.VertexBuffer.NormalKind, data.meshes[ 0 ].normals, true ); mesh.setIndices( data.meshes[ 0 ].indices ); mesh.position = new BABYLON.Vector3( 0, 0, 0 ); ...It works FINE! But!!! Without materials... I've found that multimaterial is here from the uploaded data: But if to use the next code: mesh.material = data.multiMaterials[ 0 ];Which is valid exactly for this sample, it throws the next error: Uncaught TypeError: t.needAlphaBlending is not a functionAnd I don't even know what to do next, any ideas?
  6. How can I remove mesh from scene in Babylon.js in runtime? Tried to search, didn't find, also tried to view the scene methods in debugger, also can't find.
  7. I'm using the babylonjs 3D WebGL library. It's great library, but I can't find the same, which exists in THREE.JS library. For example, I have 2D polygons in database, I'm fetching the polygon data from it and then create a custom mesh and extruding it. With the THREE.JS, there isn't any problem, I can add to some array: ... points.push( new THREE.Vector2( part.x, -part.y ) ); ... var shape = new THREE.Shape( points ); var extrusion = { amount: building.height, bevelEnabled: false }; var geometry = new THREE.ExtrudeGeometry( shape, extrusion ); var mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial({ ambient: 0xbbbbb, color: 0xff0000 }); ... scene.add( mesh );It's very simple. How to do the same, I couldn't find. I've found only some information here: - http://www.html5gamedevs.com/topic/4530-create-a-mesh-from-a-list-of-vertices-and-faces/ - http://blogs.msdn.com/b/eternalcoding/archive/2013/06/27/babylon-js-a-complete-javascript-framework-for-building-3d-games-with-html-5-and-webgl.aspx With such an example (from msdn by Ctrl + F -> `You can also create a mesh from a list of vertices and faces`): var plane = new BABYLON.Mesh(name, scene); var indices = []; var positions = []; var normals = []; var uvs = []; // Vertices var halfSize = size / 2.0; positions.push(-halfSize, -halfSize, 0); normals.push(0, 0, -1.0); uvs.push(0.0, 0.0); positions.push(halfSize, -halfSize, 0); normals.push(0, 0, -1.0); uvs.push(1.0, 0.0); positions.push(halfSize, halfSize, 0); normals.push(0, 0, -1.0); uvs.push(1.0, 1.0); positions.push(-halfSize, halfSize, 0); normals.push(0, 0, -1.0); uvs.push(0.0, 1.0); // Indices indices.push(0); indices.push(1); indices.push(2); indices.push(0); indices.push(2); indices.push(3); plane.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind); plane.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind); plane.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind); plane.setIndices(indices); return plane;But's it's rather not the same as with the THREE.JS. For example I need to count index buffer manually where in THREE.JS I don't need it, also it's a sample with plane only and I didn't find any info about extruding exactly. So... Maybe, there are some easy ways in BabylonJS?