javascriptspark-ar-studio

Spark AR - Can't create an Scene Object with Scene.create() method


My code is below, I'm getting a warning in console Possible unhandled promise rejection: Typeerror: undefined is not a function

The error trace will always point to Scene.create() method, even though according to the docs, is a valid call

https://sparkar.facebook.com/ar-studio/learn/reference/classes/scenemodule#methods

const Scene = require('Scene');
const D = require('Diagnostics');

(async function () {
  const sprites = [];

  for (const i = 0; i < 3; i++) {
    const dynamicSprite = await Scene.create("PlanarImage", {
        "name": `sprite${i}`,
        "width": 0.1,
        "height": 0.1,
        "x": 0,
        "y": 0,
        "hidden": true,
        'material' : 'material1'
    });

    sprites.push(dynamicSprite );
  }
})();

Things I checked:


Solution

  • Solved with this answer SparkAR Dynamic instantiation doesn't work at all

    Had to enable dynamic instantation in the project.