Scripts created under editor, use in non-editor html project

JS scripts created under the editor, how to introduce and use in non-editor scripts. There are no examples. For example, the orbitCamera script, how can I use it.

Hi @haku,

Check the following helper script in the engine repo. It’s being used extensively in the engine examples to load assets, and script assets, so they are made available much like in the editor:

Code example on how to use it:

1 Like

Thank you so much. This example uses the React library, which I’m not familiar with its syntax, is there any example based on ordinary JavaScript.

After the PlayCanvas application object has been created, you can use app.assets.loadFromUrl with the URL of the script.

Once the script asset has been loaded, then you can add it to a script component of an entity