ScatterCo / Depthkit.js-deprecated

🎞 A plugin for using Depthkit's volumteric captures in Three.js
https://depthkit.tv
MIT License
33 stars 11 forks source link

unable to add multiple clips / characters #12

Closed heaversm closed 4 years ago

heaversm commented 4 years ago

Hi - just getting up to speed on Depthkit in Three.js. I'm following along with the examples, and attempting to add multiple clips, but for some reason the scene seems to be storing multiple instances of only one of the clips (whichever is most recently added to the scene).

I've modified the simple example as follows:

const appState = {
  characters: [],
  curCharacter: null,
};

const config = {
  paths: {
    assets: "../../assets",
  },
  characters: [
    {
      name: "autumn",
      rotation: null,
      position: [2, 0.95, 0],
    },
    {
      name: "john",
      rotation: [Math.PI - 0.25, 0, Math.PI / -2.0],
      position: [-0.25, 0.92, 0],
    },
  ],
};

config.characters.forEach((charInfo, index) => {
  depthkit.load(
    `${config.paths.assets}/${charInfo.name}/${charInfo.name}.txt`,
    `${config.paths.assets}/${charInfo.name}/${charInfo.name}.mp4`,
    (dkCharacter) => {
      const character = dkCharacter;
      ...
      scene.add(dkCharacter);
      appState.characters.push(dkCharacter);
    }
  )
});

depthkit.video.muted = "muted"; // Necessary for auto-play in chrome now
depthkit.setLoop(true);
depthkit.play();
render();

If I limit this loop to just index 0 or 1, the individual character respectively loads and plays properly, but running through both characters in the config only renders character at index 1.

In the browser console, if I, for example, make appState.characters[0].visible = false, the change applies to appState.characters[1] as well.

multiple-char-issue