gbball Posted May 31, 2019 Share Posted May 31, 2019 <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 Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<function>, onProgress?: Nullable<function>, onError?: Nullable<function>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync> Link to comment Share on other sites More sharing options...
gbball Posted May 31, 2019 Author Share Posted May 31, 2019 <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 More sharing options...
szabesz Posted May 31, 2019 Share Posted May 31, 2019 1 hour ago, gbball said: BABYLON.SceneLoader.Append(<?php $glb?>, "Silo.glb", scene, function (scene) { You are missing an echo: <?php echo $glb?> 1 hour ago, gbball said: echo $config->urls->templates.'/glb' No big deal but "/" is not needed as the config value ends in that. 1 hour ago, gbball said: Could something like this work? I don't know what the JS code does but generating bits of it with PHP should work ? 2 Link to comment Share on other sites More sharing options...
gbball Posted May 31, 2019 Author Share Posted May 31, 2019 1 hour ago, szabesz said: You are missing an echo: <?php echo $glb?> No big deal but "/" is not needed as the config value ends in that. I don't know what the JS code does but generating bits of it with PHP should work ? Thanks! I'll give it a try! 1 Link to comment Share on other sites More sharing options...
szabesz Posted June 1, 2019 Share Posted June 1, 2019 18 hours ago, gbball said: <?php $glb = echo $config->urls->templates.'/glb' ?> Just one more thing I noticed in the code above: you do not need echo in this expression as assigning the ULR to the variable just works without it. Link to comment Share on other sites More sharing options...
gbball Posted June 3, 2019 Author Share Posted June 3, 2019 Got it working. Thanks for the help! I think I was overthinking it a bit, but since php is resolved first, it's okay to put the processwire tags inside a javascript argument. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now