Babylon.js Viewer without server (kiosk mode)

Hello

I wish to use Babylon.js Viewer in kiosk or offline mode, with no server at all.
No server to use Babylon.js Viewer
No server to import assets (model & texture)

I would like to double click on a html page with 3D babylon js script inside.
The model and texture 'll be imported from relative (local) url.
The html page should display the 3D model rotating.

Is it possible to do that ?

I tried Load a *.glb model off local drive with babylon.viewer.js - Questions & Answers - HTML5 Game Devs Forum
Solution :

I solved the issue of being able to open a *.glb file on a local drive. Placing Babylon.viewer.js and part.glb within the same folder and referencing directly as shown below in the snippet (i.e. with no folder path specification) it works.
<babylon model="part2.glb" templates.main.params.fill-screen="true"></babylon>

but it does not work with me.

Seems impossible to achieve with no server.

Thx

Hello and welcome!

It is totally possible, you can simply copy this file locally and reference it from your page:
https://preview.babylonjs.com/Viewer/babylon.viewer.js

Then you can use the viewer the way you want

But of course I tried this and it only works with url from a server ie :
<babylon model="https://models.babylonjs.com/boombox.glb" templates.main.params.fill-screen="true"></babylon>

it doesn t work with
relative url :
<babylon model="./boombox.glb" templates.main.params.fill-screen="true"></babylon>
nor with physical url :
<babylon model="C:/my8dir/boombox.glb" templates.main.params.fill-screen="true"></babylon>
For both I got error :‘No URL provided’

this is a security constraint :slight_smile: Not our fault. Browser does not serve from local files (for security reasons)

it’s what I thought.

Could n t it be possible then to transmit datas model and textures as javascript datas ?

But it would mean rewriting Babylonjs core.

lol yeah ;D

but you could convert your data to base64 and store them as string

Yeah but it means spending lots of hours or days to understand import
data model/texture process in Babylonjs to add such a functionality.

Not sure my client will accept to pay me so much and not even
sure I m good enough to do that.

Thanks a lot for answering !!

Have a nice day

Kiss from France :smiley:

.

[mailto:babylonjs@discoursemail.com]

base64 easy solution seems uncertain : Load glb model into scene directly from content string. - Questions & Answers - HTML5 Game Devs Forum
:expressionless:

it was long time ago…Now it’s working

Yeap , there s this solution : https://playground.babylonjs.com/#7F6S08#2 from https://www.html5gamedevs.com/topic/41216-load-glb-model-into-scene-directly-from-content-string/

Now, how do I convert glb model datas in base64 format ?

Search in Google something like: javascript convert binary to base64

If you already have Babylon loaded, you can use BABYLON.StringTools.EncodeArrayBufferToBase64

1 Like

I mean “how to convert files to base64”. The solution I’ve found : EmEditor Professionnal.

Here is one: File to Base64 Converter - Encode Files to Base64 - Online - Browserling Web Developer Tools

Starting from bghgary 's solution : https://playground.babylonjs.com/#7F6S08#2
Could it be possible to add texture to object ?
Always condidering it must be done without http server.

Thanx

Yes, you can. Just create a blob url like in that PG and pass it into a new Texture.

Nice,
As I m a total noob with Babylonjs and with very few time left for finishing my project, could you give some precise informations on how to do that.
I can possibly reward you with money if you write me the script (private message then).
Thanks

https://playground.babylonjs.com/#7F6S08#10

1 Like

Geat!

Last point, how can I add material to the object in your 1st script ?

BABYLON.SceneLoader.Append("", url, scene, function () { 
        scene.createDefaultCamera(true, true, true);
    }, undefined, undefined, ".obj"); 

I ll send you little money for your help because you earn it.