Miorey / wow-model-viewer

A library for displaying interactive 3D models of World of Warcraft characters, items, and NPCs on your website using data from Wowhead. Customize the display with control over camera angles and animation.
https://miorey.github.io/wow-model-viewer/
56 stars 32 forks source link

Broken Models when CONTENT_PATH endpoint set to Classic or TBC version #20

Closed nellyeo closed 1 year ago

nellyeo commented 1 year ago

First of all, thanks for this beautiful project!

Up until this week or 2 weeks ago, it was working for all content, but now when changing

CONTENT_PATH from https://wow.zamimg.com/modelviewer/live/ to https://wow.zamimg.com/modelviewer/classic/ or https://wow.zamimg.com/modelviewer/tbc/ and possibly wotlk when released it it doesn't load character textures and starts giving the following error on console repeatedly;

Uncaught TypeError: undefined has no properties viewer.min.js:2:187352
Uncaught TypeError: n is undefined
    bN https://wow.zamimg.com/modelviewer/live/viewer/viewer.min.js:2
    cc https://wow.zamimg.com/modelviewer/live/viewer/viewer.min.js:2
    ce https://wow.zamimg.com/modelviewer/live/viewer/viewer.min.js:2
    draw https://wow.zamimg.com/modelviewer/live/viewer/viewer.min.js:2
    t https://wow.zamimg.com/modelviewer/live/viewer/viewer.min.js:2
    .
    .
    .
viewer.min.js:2:187352

The problem occurs at const t=n.find((t=>t.TextureType==f)); part and When de-minifying the code, at line 6684; const t = n.find((t => t.TextureType == f));

Entire block;

const n = this.G.b.Materials,
  a = this.G.b.TextureLayers,
  o = this.G.b.TextureSections;
let l = !0,
  h = !0;
15 != this.o && 21 != this.o || (h = !1), this.y.forEach((t => {
  let e = t.e;
  4 != e && 5 != e && 19 != e || (l = !1), 7 == e && (h = !1)
}));
let u = -1;
if (27 == this.o)
  for (let t of a) 9 == t.BlendMode && 1 == t.TextureType && t.Layer > u && (u = t.Layer);
const c = (f = t => t.TextureType, a.reduce(((t, e) => {
  var i;
  return (t[i = f(e)] || (t[i] = [])).push(e), t
}), {}));
var f;
for (const s in c) {
  const a = c[s],
    f = a[0].TextureType;
  if (!this.aL[s]) {
    const t = n.find((t => t.TextureType == f));
    if (!t) {
      WH.debug("unable to find material info", f);
      continue
    }
    this.aL[s] = new wo(this.aT.context, t.Width, t.Height)
  }

Steps to reproduce;

nellyeo commented 1 year ago

Looks like they classified their viewer.min.js as well.

This has nothing to do with the project, simply changing path of viewer.min.js path by content fixes the issue.

Live: https://wow.zamimg.com/modelviewer/live/viewer/viewer.min.js Classic: https://wow.zamimg.com/modelviewer/classic/viewer/viewer.min.js TBC: https://wow.zamimg.com/modelviewer/tbc/viewer/viewer.min.js