|
|
@ -25,7 +25,8 @@ window.addEventListener("load", async () => {
|
|
|
|
|
|
|
|
|
|
|
|
part1.innerHTML = "";
|
|
|
|
part1.innerHTML = "";
|
|
|
|
part2.innerHTML = "";
|
|
|
|
part2.innerHTML = "";
|
|
|
|
const indexed = {};
|
|
|
|
const indexed = window.indexed = {};
|
|
|
|
|
|
|
|
const byName = window.byName = {};
|
|
|
|
const tree = {};
|
|
|
|
const tree = {};
|
|
|
|
const shapeCache = {};
|
|
|
|
const shapeCache = {};
|
|
|
|
|
|
|
|
|
|
|
@ -33,30 +34,22 @@ window.addEventListener("load", async () => {
|
|
|
|
headRenderer.expose();
|
|
|
|
headRenderer.expose();
|
|
|
|
|
|
|
|
|
|
|
|
for (let mesh of allMeshes) {
|
|
|
|
for (let mesh of allMeshes) {
|
|
|
|
let [_, x, race, gender, part, nr = undefined] = mesh.name.split('_');
|
|
|
|
let [_, __, race, gender, part, nr = undefined] = mesh.name.split('_');
|
|
|
|
race = race.replace(new RegExp("\\s+"), ' ');
|
|
|
|
race = race.replace(new RegExp("\\s+"), ' ');
|
|
|
|
if (race.toLowerCase() === "khajiit") {
|
|
|
|
|
|
|
|
console.log(part, mesh.name, nr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (x !== 'N') {
|
|
|
|
if (race === 'DarkElf') {
|
|
|
|
continue;
|
|
|
|
race = 'Dark Elf'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (nr === undefined) {
|
|
|
|
if (nr === undefined && !['head', 'hair'].includes(part.toLowerCase())) {
|
|
|
|
[_, part, nr] = part.match(/(head|hair)(\d+)?/i) || [];
|
|
|
|
[_, part, nr] = part.match(/(head|hair)(\d+)?/i) || [];
|
|
|
|
console.log(part);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!nr) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let option = document.createElement("option");
|
|
|
|
let option = document.createElement("option");
|
|
|
|
option.textContent = mesh.name;
|
|
|
|
option.textContent = mesh.name;
|
|
|
|
option.value = mesh.id = uuidv4();
|
|
|
|
option.value = mesh.id = uuidv4();
|
|
|
|
indexed[mesh.id] = mesh;
|
|
|
|
indexed[mesh.id] = mesh;
|
|
|
|
|
|
|
|
byName[mesh.name] = mesh.id;
|
|
|
|
|
|
|
|
|
|
|
|
if (mesh.name.toLowerCase().indexOf("hair") !== -1) {
|
|
|
|
if (mesh.name.toLowerCase().indexOf("hair") !== -1) {
|
|
|
|
part1.appendChild(option);
|
|
|
|
part1.appendChild(option);
|
|
|
@ -89,7 +82,7 @@ window.addEventListener("load", async () => {
|
|
|
|
setRace(race.value);
|
|
|
|
setRace(race.value);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function setRace(name) {
|
|
|
|
function setRace(name, propagate = true) {
|
|
|
|
race.value = name;
|
|
|
|
race.value = name;
|
|
|
|
gender.innerHTML = "";
|
|
|
|
gender.innerHTML = "";
|
|
|
|
for (let genderX in tree[name]) {
|
|
|
|
for (let genderX in tree[name]) {
|
|
|
@ -99,7 +92,9 @@ window.addEventListener("load", async () => {
|
|
|
|
gender.appendChild(option);
|
|
|
|
gender.appendChild(option);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setGender(gender.value)
|
|
|
|
if (propagate) {
|
|
|
|
|
|
|
|
setGender(gender.value)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gender.addEventListener("change", () => {
|
|
|
|
gender.addEventListener("change", () => {
|
|
|
@ -112,19 +107,66 @@ window.addEventListener("load", async () => {
|
|
|
|
setHead(tree[race.value][name]['head'][0]);
|
|
|
|
setHead(tree[race.value][name]['head'][0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setRace("Dark Elf");
|
|
|
|
// Collect hash query before setting defaults
|
|
|
|
|
|
|
|
let q = collectHashQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Dark Elf / M is what Morrowind starts you with
|
|
|
|
|
|
|
|
setRace("Dark Elf", false);
|
|
|
|
setGender("M");
|
|
|
|
setGender("M");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateFromHash(q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function collectHashQuery() {
|
|
|
|
|
|
|
|
return location.hash.substr(1).split('&').reduce((c, x) => {
|
|
|
|
|
|
|
|
let [name, value = ""] = x.split('=', 2).map(y => decodeURIComponent(y));
|
|
|
|
|
|
|
|
c[name] = value;
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updateFromHash(q) {
|
|
|
|
|
|
|
|
if (!q) {
|
|
|
|
|
|
|
|
q = collectHashQuery();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (byName[q['head']] && q['head'].toLowerCase().includes('head')) {
|
|
|
|
|
|
|
|
setHead(byName[q['head']]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (q['head']) {
|
|
|
|
|
|
|
|
console.log("No head found with name: ", q['head']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (byName[q['hair']] && q['hair'].toLowerCase().includes('hair')) {
|
|
|
|
|
|
|
|
setHair(byName[q['hair']]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (q['hair']) {
|
|
|
|
|
|
|
|
console.log("No hair found with name: ", q['hair']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateFromHash();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('hashchange', () => {
|
|
|
|
|
|
|
|
updateFromHash();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function getShape(name) {
|
|
|
|
function getShape(name) {
|
|
|
|
return new ShapeCollection(indexed[name], "blob/textures/");
|
|
|
|
return new ShapeCollection(indexed[name], "blob/textures/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updateHash() {
|
|
|
|
|
|
|
|
location.hash = `head=${encodeURIComponent(indexed[part2.value].name)}&hair=${encodeURIComponent(indexed[part1.value].name)}`;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function setHair(id) {
|
|
|
|
function setHair(id) {
|
|
|
|
part1.value = id;
|
|
|
|
part1.value = id;
|
|
|
|
if (shape1 !== null) {
|
|
|
|
if (shape1 !== null) {
|
|
|
|
headRenderer.remove(shape1);
|
|
|
|
headRenderer.remove(shape1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
headRenderer.add(shape1 = getShape(id));
|
|
|
|
headRenderer.add(shape1 = getShape(id));
|
|
|
|
|
|
|
|
updateHash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
part1.addEventListener("change", () => {
|
|
|
|
part1.addEventListener("change", () => {
|
|
|
@ -147,6 +189,7 @@ window.addEventListener("load", async () => {
|
|
|
|
headRenderer.remove(shape2);
|
|
|
|
headRenderer.remove(shape2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
headRenderer.add(shape2 = getShape(id));
|
|
|
|
headRenderer.add(shape2 = getShape(id));
|
|
|
|
|
|
|
|
updateHash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
part2.addEventListener("change", () => {
|
|
|
|
part2.addEventListener("change", () => {
|
|
|
|