Jump to content

Need to put processwire php inside a javascript string - Using Bablyon.js


gbball
 Share

Recommended Posts

<script>
//code
// Append glTF model to scene.
            BABYLON.SceneLoader.Append("<?php echo $config->urls->templates?>/glb/", "Silo.glb", scene, function (scene) {
                // Create a default arc rotate camera and light.
                scene.createDefaultCameraOrLight(true, true, true);
//code              
</script>              

I am trying to work with Bablylon.js to make a 3d comic on my Processwire site, but I need to pass a directory to the Bablylon scene loader inside of a string in the Bablylon Javascript function.

How do I tell Babylon to locate the file correctly while referencing Processwire's template directory through php?

Below is the documentation for the Bablylon Append method.

Static Append

Find examples in Playground

Link to comment
Share on other sites

<script>
//code  

<?php $glb = echo $config->urls->templates.'/glb' ?>       
            // Append glTF model to scene.
            BABYLON.SceneLoader.Append(<?php $glb?>, "Silo.glb", scene, function (scene) {
                // Create a default arc rotate camera and light.
                scene.createDefaultCameraOrLight(true, true, true);
  
//code
</script>  

Could something like this work?

Link to comment
Share on other sites

  On 5/31/2019 at 7:59 PM, gbball said:

BABYLON.SceneLoader.Append(<?php $glb?>, "Silo.glb", scene, function (scene) {

Expand  

You are missing an echo: <?php echo $glb?>

  On 5/31/2019 at 7:59 PM, gbball said:

echo $config->urls->templates.'/glb'

Expand  

No big deal but "/" is not needed as the config value ends in that.

  On 5/31/2019 at 7:59 PM, gbball said:

Could something like this work?

Expand  

I don't know what the JS code does but generating bits of it with PHP should work ?

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...