miijs 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: 20
18
+ - run: npm ci
19
+ - run: npm test
20
+
21
+ publish-gpr:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ permissions:
25
+ contents: read
26
+ packages: write
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: actions/setup-node@v4
30
+ with:
31
+ node-version: 20
32
+ registry-url: https://npm.pkg.github.com/
33
+ - run: npm ci
34
+ - run: npm publish
35
+ env:
36
+ NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
package/README.md CHANGED
@@ -47,7 +47,7 @@ MiiJS is a complete and comprehensive Mii library for reading, converting, modif
47
47
  - **`miiHeightToMeasurements(miiHeight)`** - Converts Mii height value (0-127) to real-world feet and inches. Returns `{feet, inches, totalInches, centimeters}`.
48
48
  - **`inchesToMiiHeight(totalInches)`** - Converts real-world height in inches to Mii height value (0-127).
49
49
  - **`centimetersToMiiHeight(totalCentimeters)`** - Converts real-world height in centimeters to Mii height value (0-127).
50
- - **`miiWeightToRealWeight(miiWeight)`** - Converts Mii weight value (0-127) to real-world weight values. Returns `{pounds, kilograms}`.
50
+ - **`miiHeightWeightToRealWeight(miiWeight)`** - Converts Mii weight value (0-127) to real-world weight values. Returns `{pounds, kilograms}`.
51
51
  - **`imperialHeightWeightToMiiWeight(heightInches, weightLbs)`** - Converts real-world imperial measurements to Mii weight values.
52
52
  - **`metricHeightWeightToMiiWeight(heightCentimeters, weightKilograms)`** - Converts real-world metric measurements to Mii weight values.
53
53
 
@@ -360,4 +360,4 @@ You can find FFLResHigh using a Wii U with an FTP program installed at `sys/titl
360
360
  - **[kazuki-4ys' MiiInfoEditorCTR](https://github.com/kazuki-4ys/kazuki-4ys.github.io/tree/master/web_apps/MiiInfoEditorCTR)** - I repurposed how to decrypt and reencrypt the QR codes from here, including repurposing the asmCrypto.js file in its entirety with very small modifications (it has since been stripped down to only include the functions this library uses). I believe I also modified the code for rendering the Mii using Nintendo's Mii Studio from here as well, though I do not remember for certain.
361
361
  - **[ariankordi's FFL.js](https://github.com/ariankordi/FFL.js/)** - Rendering Miis locally would not be possible without this library. Instructions for finding FFLResHigh are also learned from [ariankordi's FFL-Testing repository](https://github.com/ariankordi/FFL-Testing).
362
362
  - **[Models Resource](https://models.spriters-resource.com/3ds/systembios/asset/306260/)** - For the bodies used in Mii rendering
363
- - **[socram8888's Amiitools](https://github.com/socram8888/amiitool)** - I _think_, for the code reverse engineered to help with aspects of Amiibo dump processing. I went through so many iterations in research and coding, there may be other credits due as well but I _think_ this was the only repo actually used for the reverse engineering in the final working code.
363
+ - **[socram8888's Amiitools](https://github.com/socram8888/amiitool)** - I _think_, for the code reverse engineered to help with aspects of Amiibo dump processing. I went through so many iterations in research and coding, there may be other credits due as well but I _think_ this was the only repo actually used for the reverse engineering in the final working code.
package/index.js CHANGED
@@ -12,7 +12,6 @@ const httpsLib = require('https');
12
12
  const asmCrypto = require("./asmCrypto.js");
13
13
  const path = require("path");
14
14
  const createGL = require('gl');
15
- const typeCheat = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3];
16
15
  const {
17
16
  createCharModel, initCharModelTextures,
18
17
  initializeFFL, exitFFL, parseHexOrB64ToUint8Array,
@@ -20,6 +19,7 @@ const {
20
19
  } = require("./fflWrapper.js");
21
20
  const ModuleFFL = require("ffl.js/examples/ffl-emscripten-single-file.js");
22
21
  const FFLShaderMaterial = require("ffl.js/FFLShaderMaterial.js");
22
+ const typeCheat = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3];
23
23
 
24
24
  // Typedefs for intellisence
25
25
  /** @typedef {import('./types').WiiMii} WiiMii */
@@ -1570,6 +1570,12 @@ function makeChild(parent0, parent1, options) {
1570
1570
  if(parent0.console.toLowerCase()==="wii") parent0=convertMii(parent0,"3DS");
1571
1571
  if(parent1.console.toLowerCase()==="wii") parent1=convertMii(parent1,"3DS");
1572
1572
 
1573
+ if(parent0.general.gender!==0){
1574
+ let tempHolder=structuredClone(parent0);
1575
+ parent0=structuredClone(parent1);
1576
+ parent1=structuredClone(tempHolder);
1577
+ }
1578
+
1573
1579
  var randomBytes = [];
1574
1580
  for (var i = 0; i < 8; i++) {
1575
1581
  //randomBytes[1] is never used, kept here purely for an interesting detail from research
@@ -1601,7 +1607,6 @@ function makeChild(parent0, parent1, options) {
1601
1607
  child.meta.name = options?.hasOwnProperty("name")? options.name : childGenTables.names[child.general.gender][Math.floor(Math.random() * childGenTables.names[child.general.gender].length)];
1602
1608
 
1603
1609
  var matchingParent = parent0.general.gender === gender ? parent0 : parent1;
1604
- var mainParentFlag = (matchingParent === parent0) ? 0 : 1;
1605
1610
 
1606
1611
  //Skin color mixing. Intuitively you'd think they'd order them by similarity and pick an average, but no they have an entire table of what skin colors product what child skin color
1607
1612
  var validValues = childGenTables.skinColorMixing[Math.min(parent0.face.color, parent1.face.color)][Math.max(parent0.face.color, parent1.face.color)].filter(v => v !== -1);
@@ -1618,8 +1623,6 @@ function makeChild(parent0, parent1, options) {
1618
1623
  child.eyebrows.page = matchingParent.eyebrows.page;
1619
1624
  child.eyebrows.type = matchingParent.eyebrows.type;
1620
1625
 
1621
- child.face.color = [7, 7, 6, 7][Math.min(child.face.color, 3)];
1622
-
1623
1626
  child.eyebrows.color = child.hair.color;
1624
1627
 
1625
1628
  child.nose.page = randomBytes[5] === 0 ? parent0.nose.page : parent1.nose.page;
@@ -1683,7 +1686,7 @@ function makeChild(parent0, parent1, options) {
1683
1686
  delete child.stages[iStage].stages;//Because we're just cloning the baseline object repeatedly to make the stages a little bit cleaner, we need to clear this on subsequent clones
1684
1687
  }
1685
1688
 
1686
- //If this looks odd, it is setup in a specific way to mimic the research I did into hair generation as 1:1 as possible
1689
+ //Basically there's a random chance for a hairstyle to not advance throughout the years, so it's possible to end up with a hairstyle from a younger stage. This is slightly more likely for boys than girls.
1687
1690
  let ageGroup = 0;
1688
1691
  for (let iHairStage = 0; iHairStage < 4; iHairStage++) {
1689
1692
  const subgroup = childGenTables.hairStyleGroups[hairGroupIndex][ageGroup];
@@ -1713,25 +1716,8 @@ function makeChild(parent0, parent1, options) {
1713
1716
  child.stages[5].hair.type = hairType;
1714
1717
  break;
1715
1718
  }
1716
- if (mainParentFlag === 0) {
1717
- if (iHairStage === 0) {
1718
- ageGroup = Math.min(ageGroup + 1, 3);
1719
- }
1720
- else {
1721
- if (Math.floor(Math.random() * 3) !== 0) {
1722
- ageGroup = Math.min(ageGroup + 1, 3);
1723
- }
1724
- }
1725
- }
1726
- else {
1727
- if (iHairStage === 0) {
1728
- ageGroup = Math.min(ageGroup + 1, 3);
1729
- }
1730
- else {
1731
- if (Math.floor(Math.random() * 4) !== 0) {
1732
- ageGroup = Math.min(ageGroup + 1, 3);
1733
- }
1734
- }
1719
+ if (iHairStage === 0 || Math.floor(Math.random() * (child.stages[0].general.gender === 0 ? 3 : 4)) !== 0) {//For each stage of life there is a 33% chance for boys, and a 25% chance for girls, of staying on the same hairstyle as they had already. However, they are guaranteed to never have the same hairstyle stage as their newborn stage.
1720
+ ageGroup = Math.min(ageGroup + 1, 3);
1735
1721
  }
1736
1722
  }
1737
1723
  return child.stages;
@@ -1895,7 +1881,6 @@ function miiWeightToRealWeight(heightInches, miiWeight) {
1895
1881
 
1896
1882
  This is approximate, not guaranteed accurate nor intended to be taken that way. This is for entertainment value only.
1897
1883
  */
1898
- if (!heightInches || heightInches < 0) throw new Error("heightInches must be >= 0");
1899
1884
  const H = miiHeightToMeasurements(heightInches).totalInches;
1900
1885
  const BMI = bmiFromWeightSlider(miiWeight);
1901
1886
  return {
@@ -1904,8 +1889,6 @@ function miiWeightToRealWeight(heightInches, miiWeight) {
1904
1889
  };
1905
1890
  }
1906
1891
  function imperialHeightWeightToMiiWeight(heightInches, weightLbs) {
1907
- if (!heightInches || heightInches < 0) throw new Error("heightInches must be >= 0");
1908
-
1909
1892
  const H = miiHeightToMeasurements(heightInches).totalInches;
1910
1893
  const BMI = weightLbs * 703 / (H * H);
1911
1894
 
@@ -1919,8 +1902,6 @@ function imperialHeightWeightToMiiWeight(heightInches, weightLbs) {
1919
1902
  function metricHeightWeightToMiiWeight(heightCentimeters, weightKilograms) {
1920
1903
  const heightInches = Math.round(heightCentimeters / 2.54);
1921
1904
  const weightLbs = Math.round(weightKilograms / 0.4535924);
1922
- if (!heightInches || heightInches < 0) throw new Error("heightCentimeters must be >= 0");
1923
-
1924
1905
  const H = miiHeightToMeasurements(heightInches).totalInches;
1925
1906
  const BMI = weightLbs * 703 / (H * H);
1926
1907