tentone / nunuStudio

Web powered cross-platform 3D, WebXR game engine.
https://nunustudio.org
MIT License
2.13k stars 319 forks source link

How to use nunu with Nuxtjs #520

Closed oneWaveAdrian closed 2 years ago

oneWaveAdrian commented 2 years ago

Took me a couple hours to figure out so I want to share my knowledge:

  1. Build nunu.min.js and place into static/js folder of your nuxt instance
  2. Place canvas element into your template area where you want it, for example:
    <template>
    <div>
    <canvas
      id="canvas"
      width="800"
      height="480"
    />
    </div>
    </template>
  3. Add the script to your head function of the page you want the 3D integration on (or place is into your global head)
    head() {
    return {
      script: [
        {
          hid: 'Nunu',
          src: 'assets/js/nunu.min.js',
          defer: true,
          callback: () => {
            Nunu.App.loadApp('assets/file.nsp', 'canvas') //add file to load in here
          },
        },
      ],
    },
    }

You are now able to address Nunu as usual within the app.

tentone commented 2 years ago

Hi.

Thanks a lot for sharing this knowledge.

I will add this info to the readme of the project so that everybody can find it easily.

Thanks a lot

Cheers