How do I find the root url to the Files folder? JAVASCRIPT

  • Hello, I was just wondering how or what the root URL was to the files folder. Any help would be much appreciated.

    for example

    	action("RootUrlHere", "Filename.Filetypehere")
    
  • It's the same as the main document, so the usual location object should tell you this. What do you need it for anyway? You don't normally need to specify a full URL.

  • Hey Ashley, thanks for getting back to me.

    Sorry, I am no coder, so may need a little clarification in terms of what the location object is.

    I am trying to jerry-rig Babylon.js into construct 3 (just for some advanced 2D animations as there a very few options (both spine and spriter eat up the CPU whereas WebGL 2.5D is very stable))

    	var alienload = BABYLON.SceneLoader.Append(location, "alien.glb", scene,
    

    Is this what you mean by location?

  • No, I meant the properties of the location object, e.g. location.href. But that won't work in preview or remote preview, because the game is not uploaded anywhere yet. To load project files you should use AssetManager methods, e.g. await runtime.assets.fetchBlob("alien.glb").

  • Side note: I did a template for Babylon with a plugin to allow the Babylon image integrated as a C3 object.

    construct.net/en/forum/construct-3/general-discussion-7/babylon-3d-simple-js-147886

    In my case, I am downloading scene files from the web during runtime.

    How were you planning on integrating in the Babylon image to C3, I am interested if you have another technique.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi Mikal

    I was actually using your template to get things off the ground. I striped it down and changed things in regards to getting the model in so that you can change the animation from with in the event sheets by calling a different functions that changes animation within the animation group.

    I also made all the js libraries local to the game.

    It was working quite well with glp models off the internet (with root url) but I still can't work out how to refer to an object from within the root file of the local game.

    But I am no programmer so I got stuck there.

    I was hoping to use it to display "3D" rendered sprites in a 2D world. It was far more computationally efficient as well as easier for me (a am a 3d artist).

    After I worked out that part I was going to look at how to transition one animation to the next.

    In the end it was becoming a far greater headache than it should have been so I shelved it for a later date.

  • HaydenF

    This is exactly the type of problem that fires me up to grind out a solution. Sometimes it ends in pain and no solution, other times you go through the weeds, a few google searches, debugging and find an answer!

    BabylonTemplateLocal.c3p

    So a couple of things:

    I used the C3 SDK to get the project file URL in preview mode (e.g. the blob based name), since this blob URL no longer has the *.glb file extension, I changed babylon.js to default to .glb instead of .babylon. So, for this to work in preview, you need to use .glb files for your models.

    The C3 project file URL SDK also works for web (and mobile), so on export, it also works to get files 'locally' (and is actually easier since the file extension is preserved on the web export.)

    I moved the Babylon scripts to be local (because I had to modify one of them.)

    Good luck with your 3D animations and C3, I hope to see an example of them integrated with C3 someday.

  • Mikal

    Wow! That is some serious problem-solving. Thank you so much! You make it look so simple (I know it isn't but still!)

    I am going to play around with it after the weekend!

    Thank you! I really appreciate it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)