@promptbook/node 0.112.0-65 โ 0.112.0-66
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.
- package/esm/index.es.js +702 -61
- package/esm/index.es.js.map +1 -1
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/esm/src/avatars/visuals/minecraft2AvatarVisual.d.ts +7 -0
- package/esm/src/avatars/visuals/minecraftAvatarVisualShared.d.ts +48 -0
- package/esm/src/cli/cli-commands/coder/ensureCoderGitignoreFile.d.ts +1 -1
- package/esm/src/config.d.ts +3 -3
- package/esm/src/utils/files/getPromptbookTempPath.d.ts +24 -0
- package/esm/src/utils/files/getPromptbookTempPath.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +701 -60
- package/umd/index.umd.js.map +1 -1
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/umd/src/avatars/visuals/minecraft2AvatarVisual.d.ts +7 -0
- package/umd/src/avatars/visuals/minecraftAvatarVisualShared.d.ts +48 -0
- package/umd/src/cli/cli-commands/coder/ensureCoderGitignoreFile.d.ts +1 -1
- package/umd/src/config.d.ts +3 -3
- package/umd/src/utils/files/getPromptbookTempPath.d.ts +24 -0
- package/umd/src/utils/files/getPromptbookTempPath.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-66';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -967,6 +967,29 @@
|
|
|
967
967
|
}
|
|
968
968
|
// TODO: Maybe implement by mix+hsl
|
|
969
969
|
|
|
970
|
+
/**
|
|
971
|
+
* Relative directory name without the `./` prefix for Git ignore rules and glob patterns.
|
|
972
|
+
*
|
|
973
|
+
* @private internal utility for Promptbook-owned temp files
|
|
974
|
+
*/
|
|
975
|
+
const PROMPTBOOK_TEMP_DIRECTORY_NAME = '.promptbook';
|
|
976
|
+
/**
|
|
977
|
+
* Builds one project-relative path inside the shared Promptbook working directory.
|
|
978
|
+
*
|
|
979
|
+
* @private internal utility for Promptbook-owned temp files
|
|
980
|
+
*/
|
|
981
|
+
function getPromptbookTempPath(...pathSegments) {
|
|
982
|
+
return `./${getPromptbookTempPosixPath(...pathSegments)}`;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Builds one POSIX path fragment inside the shared Promptbook working directory for globs and generated text files.
|
|
986
|
+
*
|
|
987
|
+
* @private internal utility for Promptbook-owned temp files
|
|
988
|
+
*/
|
|
989
|
+
function getPromptbookTempPosixPath(...pathSegments) {
|
|
990
|
+
return path.posix.join(PROMPTBOOK_TEMP_DIRECTORY_NAME, ...pathSegments);
|
|
991
|
+
}
|
|
992
|
+
|
|
970
993
|
/**
|
|
971
994
|
* Returns the same value that is passed as argument.
|
|
972
995
|
* No side effects.
|
|
@@ -1161,7 +1184,6 @@
|
|
|
1161
1184
|
*/
|
|
1162
1185
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [๐คนโโ๏ธ]
|
|
1163
1186
|
// <- TODO: [๐] Make also `AGENTS_DIRNAME_ALTERNATIVES`
|
|
1164
|
-
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
1165
1187
|
/**
|
|
1166
1188
|
* Where to store the temporary downloads
|
|
1167
1189
|
*
|
|
@@ -1169,7 +1191,15 @@
|
|
|
1169
1191
|
*
|
|
1170
1192
|
* @public exported from `@promptbook/core`
|
|
1171
1193
|
*/
|
|
1172
|
-
const DEFAULT_DOWNLOAD_CACHE_DIRNAME = '
|
|
1194
|
+
const DEFAULT_DOWNLOAD_CACHE_DIRNAME = getPromptbookTempPath('download-cache');
|
|
1195
|
+
/**
|
|
1196
|
+
* Where to store the cache of executions for promptbook CLI
|
|
1197
|
+
*
|
|
1198
|
+
* Note: When the folder does not exist, it is created recursively
|
|
1199
|
+
*
|
|
1200
|
+
* @public exported from `@promptbook/core`
|
|
1201
|
+
*/
|
|
1202
|
+
getPromptbookTempPath('execution-cache');
|
|
1173
1203
|
/**
|
|
1174
1204
|
* Where to store the scrape cache
|
|
1175
1205
|
*
|
|
@@ -1177,7 +1207,7 @@
|
|
|
1177
1207
|
*
|
|
1178
1208
|
* @public exported from `@promptbook/core`
|
|
1179
1209
|
*/
|
|
1180
|
-
const DEFAULT_SCRAPE_CACHE_DIRNAME = '
|
|
1210
|
+
const DEFAULT_SCRAPE_CACHE_DIRNAME = getPromptbookTempPath('scrape-cache');
|
|
1181
1211
|
/*
|
|
1182
1212
|
TODO: [๐]
|
|
1183
1213
|
/**
|
|
@@ -18671,6 +18701,177 @@
|
|
|
18671
18701
|
context.restore();
|
|
18672
18702
|
}
|
|
18673
18703
|
|
|
18704
|
+
/* eslint-disable no-magic-numbers */
|
|
18705
|
+
/**
|
|
18706
|
+
* Builds the seeded six-face texture pack used by the Minecraft-style head cuboid.
|
|
18707
|
+
*
|
|
18708
|
+
* @param random Seeded random generator.
|
|
18709
|
+
* @param palette Derived avatar palette.
|
|
18710
|
+
* @param hasHeadband Whether the generated avatar should include a colored headband.
|
|
18711
|
+
* @returns Head cuboid textures.
|
|
18712
|
+
*
|
|
18713
|
+
* @private helper of the Minecraft avatar visuals
|
|
18714
|
+
*/
|
|
18715
|
+
function createMinecraftHeadTextures(random, palette, hasHeadband) {
|
|
18716
|
+
const faceTexture = createMinecraftFaceTexture(random, palette, hasHeadband);
|
|
18717
|
+
const hairColor = random() < 0.5 ? palette.primary : palette.secondary;
|
|
18718
|
+
const skinColor = palette.highlight;
|
|
18719
|
+
const headbandColor = hasHeadband ? palette.accent : hairColor;
|
|
18720
|
+
const sideTexture = createFilledTexture(skinColor);
|
|
18721
|
+
const backTexture = createFilledTexture(skinColor);
|
|
18722
|
+
const topTexture = createFilledTexture(hairColor);
|
|
18723
|
+
const bottomTexture = createFilledTexture(`${palette.shadow}cc`);
|
|
18724
|
+
fillTextureRect(sideTexture, 0, 0, 8, 3, hairColor);
|
|
18725
|
+
fillTextureRect(backTexture, 0, 0, 8, 5, hairColor);
|
|
18726
|
+
fillTextureRect(backTexture, 1, 5, 6, 1, hairColor);
|
|
18727
|
+
if (hasHeadband) {
|
|
18728
|
+
fillTextureRect(sideTexture, 0, 2, 8, 1, headbandColor);
|
|
18729
|
+
fillTextureRect(backTexture, 0, 2, 8, 1, headbandColor);
|
|
18730
|
+
fillTextureRect(topTexture, 0, 4, 8, 1, headbandColor);
|
|
18731
|
+
}
|
|
18732
|
+
sideTexture[4][4] = `${palette.shadow}99`;
|
|
18733
|
+
sideTexture[5][4] = `${palette.shadow}cc`;
|
|
18734
|
+
backTexture[6][2] = `${palette.shadow}99`;
|
|
18735
|
+
backTexture[6][5] = `${palette.shadow}99`;
|
|
18736
|
+
return {
|
|
18737
|
+
front: faceTexture,
|
|
18738
|
+
back: backTexture,
|
|
18739
|
+
left: sideTexture,
|
|
18740
|
+
right: mirrorMinecraftTexture(sideTexture),
|
|
18741
|
+
top: topTexture,
|
|
18742
|
+
bottom: bottomTexture,
|
|
18743
|
+
};
|
|
18744
|
+
}
|
|
18745
|
+
/**
|
|
18746
|
+
* Builds the seeded six-face texture pack used by the Minecraft-style torso cuboid.
|
|
18747
|
+
*
|
|
18748
|
+
* @param random Seeded random generator.
|
|
18749
|
+
* @param palette Derived avatar palette.
|
|
18750
|
+
* @returns Torso cuboid textures.
|
|
18751
|
+
*
|
|
18752
|
+
* @private helper of the Minecraft avatar visuals
|
|
18753
|
+
*/
|
|
18754
|
+
function createMinecraftTorsoTextures(random, palette) {
|
|
18755
|
+
const frontTexture = createMinecraftShirtTexture(random, palette);
|
|
18756
|
+
const sideTexture = createFilledTexture(palette.primary);
|
|
18757
|
+
const backTexture = createFilledTexture(palette.primary);
|
|
18758
|
+
const topTexture = createFilledTexture(`${palette.highlight}dd`);
|
|
18759
|
+
const bottomTexture = createFilledTexture(`${palette.shadow}dd`);
|
|
18760
|
+
const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
|
|
18761
|
+
fillTextureRect(sideTexture, 0, 0, 8, 2, palette.shadow);
|
|
18762
|
+
fillTextureRect(backTexture, 0, 0, 8, 2, palette.shadow);
|
|
18763
|
+
fillTextureRect(backTexture, 3, 2, 2, 6, stripeColor);
|
|
18764
|
+
fillTextureRect(sideTexture, 4, 2, 1, 6, stripeColor);
|
|
18765
|
+
fillTextureRect(topTexture, 0, 0, 8, 2, palette.shadow);
|
|
18766
|
+
fillTextureRect(topTexture, 2, 2, 4, 4, stripeColor);
|
|
18767
|
+
return {
|
|
18768
|
+
front: frontTexture,
|
|
18769
|
+
back: backTexture,
|
|
18770
|
+
left: sideTexture,
|
|
18771
|
+
right: mirrorMinecraftTexture(sideTexture),
|
|
18772
|
+
top: topTexture,
|
|
18773
|
+
bottom: bottomTexture,
|
|
18774
|
+
};
|
|
18775
|
+
}
|
|
18776
|
+
/**
|
|
18777
|
+
* Mirrors one Minecraft texture horizontally.
|
|
18778
|
+
*
|
|
18779
|
+
* @param texture Source texture.
|
|
18780
|
+
* @returns Mirrored texture copy.
|
|
18781
|
+
*
|
|
18782
|
+
* @private helper of the Minecraft avatar visuals
|
|
18783
|
+
*/
|
|
18784
|
+
function mirrorMinecraftTexture(texture) {
|
|
18785
|
+
return texture.map((row) => [...row].reverse());
|
|
18786
|
+
}
|
|
18787
|
+
/**
|
|
18788
|
+
* Creates the front-face pixel texture for the cube head.
|
|
18789
|
+
*
|
|
18790
|
+
* @param random Seeded random generator.
|
|
18791
|
+
* @param palette Derived avatar palette.
|
|
18792
|
+
* @param hasHeadband Whether the avatar should render a headband row.
|
|
18793
|
+
* @returns 8x8 pixel texture.
|
|
18794
|
+
*
|
|
18795
|
+
* @private helper of the Minecraft avatar visuals
|
|
18796
|
+
*/
|
|
18797
|
+
function createMinecraftFaceTexture(random, palette, hasHeadband) {
|
|
18798
|
+
const texture = createFilledTexture(palette.highlight);
|
|
18799
|
+
const hairlineColor = random() < 0.5 ? palette.primary : palette.secondary;
|
|
18800
|
+
const cheekColor = random() < 0.5 ? `${palette.accent}bb` : `${palette.secondary}bb`;
|
|
18801
|
+
fillTextureRect(texture, 0, 0, 8, 2, hairlineColor);
|
|
18802
|
+
texture[2][0] = hairlineColor;
|
|
18803
|
+
texture[2][7] = hairlineColor;
|
|
18804
|
+
texture[3][0] = hairlineColor;
|
|
18805
|
+
texture[3][7] = hairlineColor;
|
|
18806
|
+
if (hasHeadband) {
|
|
18807
|
+
fillTextureRect(texture, 0, 2, 8, 1, palette.accent);
|
|
18808
|
+
}
|
|
18809
|
+
texture[3][2] = palette.ink;
|
|
18810
|
+
texture[3][5] = palette.ink;
|
|
18811
|
+
texture[4][2] = '#ffffff';
|
|
18812
|
+
texture[4][5] = '#ffffff';
|
|
18813
|
+
texture[5][1] = cheekColor;
|
|
18814
|
+
texture[5][6] = cheekColor;
|
|
18815
|
+
texture[5][3] = palette.shadow;
|
|
18816
|
+
texture[5][4] = palette.shadow;
|
|
18817
|
+
texture[6][3] = palette.shadow;
|
|
18818
|
+
texture[6][4] = palette.shadow;
|
|
18819
|
+
return texture;
|
|
18820
|
+
}
|
|
18821
|
+
/**
|
|
18822
|
+
* Creates the front-face pixel texture for the torso.
|
|
18823
|
+
*
|
|
18824
|
+
* @param random Seeded random generator.
|
|
18825
|
+
* @param palette Derived avatar palette.
|
|
18826
|
+
* @returns 8x8 torso texture.
|
|
18827
|
+
*
|
|
18828
|
+
* @private helper of the Minecraft avatar visuals
|
|
18829
|
+
*/
|
|
18830
|
+
function createMinecraftShirtTexture(random, palette) {
|
|
18831
|
+
const texture = createFilledTexture(palette.primary);
|
|
18832
|
+
const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
|
|
18833
|
+
fillTextureRect(texture, 0, 0, 8, 2, palette.shadow);
|
|
18834
|
+
for (let rowIndex = 2; rowIndex < 8; rowIndex++) {
|
|
18835
|
+
texture[rowIndex][3] = stripeColor;
|
|
18836
|
+
texture[rowIndex][4] = stripeColor;
|
|
18837
|
+
}
|
|
18838
|
+
texture[4][1] = palette.accent;
|
|
18839
|
+
texture[4][6] = palette.accent;
|
|
18840
|
+
texture[5][2] = palette.highlight;
|
|
18841
|
+
texture[5][5] = palette.highlight;
|
|
18842
|
+
return texture;
|
|
18843
|
+
}
|
|
18844
|
+
/**
|
|
18845
|
+
* Creates one solid-color 8x8 Minecraft texture.
|
|
18846
|
+
*
|
|
18847
|
+
* @param color Fill color.
|
|
18848
|
+
* @returns Filled 8x8 texture.
|
|
18849
|
+
*
|
|
18850
|
+
* @private helper of the Minecraft avatar visuals
|
|
18851
|
+
*/
|
|
18852
|
+
function createFilledTexture(color) {
|
|
18853
|
+
return Array.from({ length: 8 }, () => Array.from({ length: 8 }, () => color));
|
|
18854
|
+
}
|
|
18855
|
+
/**
|
|
18856
|
+
* Fills one rectangular area inside a mutable Minecraft texture.
|
|
18857
|
+
*
|
|
18858
|
+
* @param texture Mutable target texture.
|
|
18859
|
+
* @param x Left texture coordinate.
|
|
18860
|
+
* @param y Top texture coordinate.
|
|
18861
|
+
* @param width Rectangle width.
|
|
18862
|
+
* @param height Rectangle height.
|
|
18863
|
+
* @param color Fill color.
|
|
18864
|
+
*
|
|
18865
|
+
* @private helper of the Minecraft avatar visuals
|
|
18866
|
+
*/
|
|
18867
|
+
function fillTextureRect(texture, x, y, width, height, color) {
|
|
18868
|
+
for (let rowIndex = y; rowIndex < y + height; rowIndex++) {
|
|
18869
|
+
for (let columnIndex = x; columnIndex < x + width; columnIndex++) {
|
|
18870
|
+
texture[rowIndex][columnIndex] = color;
|
|
18871
|
+
}
|
|
18872
|
+
}
|
|
18873
|
+
}
|
|
18874
|
+
|
|
18674
18875
|
/* eslint-disable no-magic-numbers */
|
|
18675
18876
|
/**
|
|
18676
18877
|
* Minecraft-style 3D avatar visual.
|
|
@@ -18695,8 +18896,8 @@
|
|
|
18695
18896
|
const bodyX = size * 0.33;
|
|
18696
18897
|
const bodyY = headY + headSize * 0.96;
|
|
18697
18898
|
const hasHeadband = random() < 0.5;
|
|
18698
|
-
const
|
|
18699
|
-
const
|
|
18899
|
+
const headTextures = createMinecraftHeadTextures(createRandom('minecraft-face'), palette, hasHeadband);
|
|
18900
|
+
const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft-shirt'), palette);
|
|
18700
18901
|
drawAvatarFrame(context, size, palette);
|
|
18701
18902
|
const spotlight = context.createRadialGradient(size * 0.5, size * 0.18, size * 0.05, size * 0.5, size * 0.18, size * 0.5);
|
|
18702
18903
|
spotlight.addColorStop(0, `${palette.highlight}66`);
|
|
@@ -18716,7 +18917,7 @@
|
|
|
18716
18917
|
width: bodyWidth,
|
|
18717
18918
|
height: bodyHeight,
|
|
18718
18919
|
depth: bodyDepth,
|
|
18719
|
-
frontTexture:
|
|
18920
|
+
frontTexture: torsoTextures.front,
|
|
18720
18921
|
topColor: `${palette.highlight}cc`,
|
|
18721
18922
|
sideColor: `${palette.secondary}dd`,
|
|
18722
18923
|
outlineColor: `${palette.shadow}aa`,
|
|
@@ -18727,7 +18928,7 @@
|
|
|
18727
18928
|
width: headSize,
|
|
18728
18929
|
height: headSize,
|
|
18729
18930
|
depth,
|
|
18730
|
-
frontTexture:
|
|
18931
|
+
frontTexture: headTextures.front,
|
|
18731
18932
|
topColor: `${palette.highlight}ee`,
|
|
18732
18933
|
sideColor: `${palette.secondary}ee`,
|
|
18733
18934
|
outlineColor: `${palette.shadow}cc`,
|
|
@@ -18792,72 +18993,505 @@
|
|
|
18792
18993
|
context.closePath();
|
|
18793
18994
|
context.stroke();
|
|
18794
18995
|
}
|
|
18996
|
+
|
|
18997
|
+
/* eslint-disable no-magic-numbers */
|
|
18795
18998
|
/**
|
|
18796
|
-
*
|
|
18999
|
+
* Fixed scene camera distance used for the proper-3D projection.
|
|
18797
19000
|
*
|
|
18798
|
-
* @
|
|
19001
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19002
|
+
*/
|
|
19003
|
+
const CAMERA_DISTANCE_RATIO = 1.4;
|
|
19004
|
+
/**
|
|
19005
|
+
* Shared light direction used to shade projected cuboid faces.
|
|
19006
|
+
*
|
|
19007
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19008
|
+
*/
|
|
19009
|
+
const LIGHT_DIRECTION = normalizeVector3({
|
|
19010
|
+
x: 0.4,
|
|
19011
|
+
y: -0.65,
|
|
19012
|
+
z: 0.92,
|
|
19013
|
+
});
|
|
19014
|
+
/**
|
|
19015
|
+
* Minecraft 3D 2 avatar visual.
|
|
19016
|
+
*
|
|
19017
|
+
* @private built-in avatar visual
|
|
19018
|
+
*/
|
|
19019
|
+
const minecraft2AvatarVisual = {
|
|
19020
|
+
id: 'minecraft2',
|
|
19021
|
+
title: 'Minecraft 3D 2',
|
|
19022
|
+
description: 'Proper 3D Minecraft-style portrait with textured cuboids and pointer-driven head turns.',
|
|
19023
|
+
isAnimated: true,
|
|
19024
|
+
supportsPointerTracking: true,
|
|
19025
|
+
render({ context, size, palette, createRandom, timeMs, interaction }) {
|
|
19026
|
+
const spotlightY = size * 0.22;
|
|
19027
|
+
const headRandom = createRandom('minecraft2-head');
|
|
19028
|
+
const hasHeadband = headRandom() < 0.5;
|
|
19029
|
+
const headTextures = createMinecraftHeadTextures(createRandom('minecraft2-head-textures'), palette, hasHeadband);
|
|
19030
|
+
const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft2-body-textures'), palette);
|
|
19031
|
+
const bob = Math.sin(timeMs / 880) * size * 0.014;
|
|
19032
|
+
const bodyYaw = -0.24 + Math.sin(timeMs / 2300) * 0.06 + interaction.bodyOffsetX * 0.16;
|
|
19033
|
+
const bodyPitch = -0.12 + Math.cos(timeMs / 2800) * 0.02 - interaction.bodyOffsetY * 0.06;
|
|
19034
|
+
const headYaw = -0.18 + Math.sin(timeMs / 1900 + 0.6) * 0.05 + interaction.gazeX * 0.62;
|
|
19035
|
+
const headPitch = -0.12 + Math.cos(timeMs / 2400 + 1.1) * 0.03 - interaction.gazeY * 0.38;
|
|
19036
|
+
const sceneCenterX = size * 0.5;
|
|
19037
|
+
const sceneCenterY = size * 0.57;
|
|
19038
|
+
const bodyWidth = size * 0.225;
|
|
19039
|
+
const bodyHeight = size * 0.245;
|
|
19040
|
+
const bodyDepth = size * 0.145;
|
|
19041
|
+
const headSize = size * 0.24;
|
|
19042
|
+
const headLift = size * 0.205;
|
|
19043
|
+
const headForwardShift = interaction.intensity * size * 0.018;
|
|
19044
|
+
const sceneCuboids = [
|
|
19045
|
+
{
|
|
19046
|
+
center: {
|
|
19047
|
+
x: interaction.bodyOffsetX * size * 0.026,
|
|
19048
|
+
y: size * 0.05 + interaction.bodyOffsetY * size * 0.018 + bob,
|
|
19049
|
+
z: 0,
|
|
19050
|
+
},
|
|
19051
|
+
width: bodyWidth,
|
|
19052
|
+
height: bodyHeight,
|
|
19053
|
+
depth: bodyDepth,
|
|
19054
|
+
rotationX: bodyPitch,
|
|
19055
|
+
rotationY: bodyYaw,
|
|
19056
|
+
textures: torsoTextures,
|
|
19057
|
+
outlineColor: `${palette.shadow}cc`,
|
|
19058
|
+
},
|
|
19059
|
+
{
|
|
19060
|
+
center: {
|
|
19061
|
+
x: interaction.bodyOffsetX * size * 0.018 + interaction.gazeX * size * 0.016,
|
|
19062
|
+
y: -headLift + bob * 1.15,
|
|
19063
|
+
z: headForwardShift,
|
|
19064
|
+
},
|
|
19065
|
+
width: headSize,
|
|
19066
|
+
height: headSize,
|
|
19067
|
+
depth: headSize,
|
|
19068
|
+
rotationX: headPitch,
|
|
19069
|
+
rotationY: headYaw,
|
|
19070
|
+
textures: headTextures,
|
|
19071
|
+
outlineColor: `${palette.shadow}dd`,
|
|
19072
|
+
},
|
|
19073
|
+
];
|
|
19074
|
+
const visibleFaces = sceneCuboids
|
|
19075
|
+
.flatMap((cuboid) => resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY))
|
|
19076
|
+
.sort((firstFace, secondFace) => firstFace.averageDepth - secondFace.averageDepth);
|
|
19077
|
+
drawAvatarFrame(context, size, palette);
|
|
19078
|
+
drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs);
|
|
19079
|
+
drawMinecraftShadow(context, size, palette, interaction, timeMs);
|
|
19080
|
+
for (const visibleFace of visibleFaces) {
|
|
19081
|
+
drawTexturedProjectedFace(context, visibleFace);
|
|
19082
|
+
}
|
|
19083
|
+
},
|
|
19084
|
+
};
|
|
19085
|
+
/**
|
|
19086
|
+
* Draws the shared background atmosphere behind the Minecraft 3D 2 portrait.
|
|
19087
|
+
*
|
|
19088
|
+
* @param context Canvas 2D context.
|
|
19089
|
+
* @param size Canvas size in CSS pixels.
|
|
18799
19090
|
* @param palette Derived avatar palette.
|
|
18800
|
-
* @param
|
|
18801
|
-
* @
|
|
19091
|
+
* @param sceneCenterX Horizontal scene center.
|
|
19092
|
+
* @param spotlightY Vertical spotlight anchor.
|
|
19093
|
+
* @param interaction Smoothed pointer-aware interaction state.
|
|
19094
|
+
* @param timeMs Current animation time in milliseconds.
|
|
18802
19095
|
*
|
|
18803
|
-
* @private helper of `
|
|
19096
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
18804
19097
|
*/
|
|
18805
|
-
function
|
|
18806
|
-
const
|
|
18807
|
-
|
|
18808
|
-
|
|
18809
|
-
|
|
18810
|
-
|
|
18811
|
-
|
|
19098
|
+
function drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs) {
|
|
19099
|
+
const spotlightGradient = context.createRadialGradient(sceneCenterX + interaction.gazeX * size * 0.08, spotlightY + interaction.gazeY * size * 0.05, size * 0.03, sceneCenterX, spotlightY, size * 0.52);
|
|
19100
|
+
spotlightGradient.addColorStop(0, `${palette.highlight}66`);
|
|
19101
|
+
spotlightGradient.addColorStop(0.42, `${palette.accent}1d`);
|
|
19102
|
+
spotlightGradient.addColorStop(1, `${palette.highlight}00`);
|
|
19103
|
+
context.fillStyle = spotlightGradient;
|
|
19104
|
+
context.fillRect(0, 0, size, size);
|
|
19105
|
+
const rimGradient = context.createLinearGradient(0, size * 0.14, 0, size * 0.92);
|
|
19106
|
+
rimGradient.addColorStop(0, `${palette.highlight}12`);
|
|
19107
|
+
rimGradient.addColorStop(0.55, `${palette.secondary}0a`);
|
|
19108
|
+
rimGradient.addColorStop(1, `${palette.shadow}00`);
|
|
19109
|
+
context.fillStyle = rimGradient;
|
|
19110
|
+
context.fillRect(0, 0, size, size);
|
|
19111
|
+
context.save();
|
|
19112
|
+
context.globalAlpha = 0.08 + interaction.intensity * 0.04;
|
|
19113
|
+
context.fillStyle = palette.highlight;
|
|
19114
|
+
context.beginPath();
|
|
19115
|
+
context.arc(size * 0.72 + Math.sin(timeMs / 1600) * size * 0.03, size * 0.2 + Math.cos(timeMs / 1400) * size * 0.018, size * 0.025, 0, Math.PI * 2);
|
|
19116
|
+
context.fill();
|
|
19117
|
+
context.restore();
|
|
19118
|
+
}
|
|
19119
|
+
/**
|
|
19120
|
+
* Draws the soft floor shadow used to anchor the cuboids in the frame.
|
|
19121
|
+
*
|
|
19122
|
+
* @param context Canvas 2D context.
|
|
19123
|
+
* @param size Canvas size in CSS pixels.
|
|
19124
|
+
* @param palette Derived avatar palette.
|
|
19125
|
+
* @param interaction Smoothed pointer-aware interaction state.
|
|
19126
|
+
* @param timeMs Current animation time in milliseconds.
|
|
19127
|
+
*
|
|
19128
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19129
|
+
*/
|
|
19130
|
+
function drawMinecraftShadow(context, size, palette, interaction, timeMs) {
|
|
19131
|
+
context.save();
|
|
19132
|
+
context.fillStyle = `${palette.shadow}66`;
|
|
19133
|
+
context.filter = `blur(${size * 0.02}px)`;
|
|
19134
|
+
context.beginPath();
|
|
19135
|
+
context.ellipse(size * 0.5 + interaction.gazeX * size * 0.03, size * 0.85 + Math.sin(timeMs / 880) * size * 0.01, size * (0.16 + interaction.intensity * 0.015), size * 0.055, 0, 0, Math.PI * 2);
|
|
19136
|
+
context.fill();
|
|
19137
|
+
context.restore();
|
|
19138
|
+
}
|
|
19139
|
+
/**
|
|
19140
|
+
* Resolves all visible projected faces for one scene cuboid.
|
|
19141
|
+
*
|
|
19142
|
+
* @param cuboid Scene cuboid definition.
|
|
19143
|
+
* @param size Canvas size in CSS pixels.
|
|
19144
|
+
* @param sceneCenterX Horizontal scene center.
|
|
19145
|
+
* @param sceneCenterY Vertical scene center.
|
|
19146
|
+
* @returns Visible faces sorted later by depth.
|
|
19147
|
+
*
|
|
19148
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19149
|
+
*/
|
|
19150
|
+
function resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY) {
|
|
19151
|
+
const halfWidth = cuboid.width / 2;
|
|
19152
|
+
const halfHeight = cuboid.height / 2;
|
|
19153
|
+
const halfDepth = cuboid.depth / 2;
|
|
19154
|
+
const faceDefinitions = [
|
|
19155
|
+
{
|
|
19156
|
+
texture: cuboid.textures.front,
|
|
19157
|
+
corners: [
|
|
19158
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
19159
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
19160
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
19161
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
19162
|
+
],
|
|
19163
|
+
},
|
|
19164
|
+
{
|
|
19165
|
+
texture: cuboid.textures.back,
|
|
19166
|
+
corners: [
|
|
19167
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19168
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19169
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
19170
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
19171
|
+
],
|
|
19172
|
+
},
|
|
19173
|
+
{
|
|
19174
|
+
texture: cuboid.textures.right,
|
|
19175
|
+
corners: [
|
|
19176
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
19177
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19178
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
19179
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
19180
|
+
],
|
|
19181
|
+
},
|
|
19182
|
+
{
|
|
19183
|
+
texture: cuboid.textures.left,
|
|
19184
|
+
corners: [
|
|
19185
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19186
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
19187
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
19188
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
19189
|
+
],
|
|
19190
|
+
},
|
|
19191
|
+
{
|
|
19192
|
+
texture: cuboid.textures.top,
|
|
19193
|
+
corners: [
|
|
19194
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19195
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19196
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
19197
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
19198
|
+
],
|
|
19199
|
+
},
|
|
19200
|
+
{
|
|
19201
|
+
texture: cuboid.textures.bottom,
|
|
19202
|
+
corners: [
|
|
19203
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
19204
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
19205
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
19206
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
19207
|
+
],
|
|
19208
|
+
},
|
|
19209
|
+
];
|
|
19210
|
+
const visibleFaces = faceDefinitions
|
|
19211
|
+
.map((faceDefinition) => {
|
|
19212
|
+
const transformedCorners = faceDefinition.corners.map((corner) => transformScenePoint(corner, cuboid.center, cuboid.rotationX, cuboid.rotationY));
|
|
19213
|
+
const faceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
|
|
19214
|
+
if (faceNormal.z <= 0.02) {
|
|
19215
|
+
return null;
|
|
18812
19216
|
}
|
|
19217
|
+
const projectedCorners = transformedCorners.map((corner) => projectScenePoint(corner, size, sceneCenterX, sceneCenterY));
|
|
19218
|
+
return {
|
|
19219
|
+
corners: projectedCorners,
|
|
19220
|
+
texture: faceDefinition.texture,
|
|
19221
|
+
averageDepth: transformedCorners.reduce((depthSum, corner) => depthSum + corner.z, 0) / transformedCorners.length,
|
|
19222
|
+
lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION), -1, 1),
|
|
19223
|
+
outlineColor: cuboid.outlineColor,
|
|
19224
|
+
};
|
|
19225
|
+
});
|
|
19226
|
+
return visibleFaces.filter((visibleFace) => visibleFace !== null);
|
|
19227
|
+
}
|
|
19228
|
+
/**
|
|
19229
|
+
* Draws one projected textured face by tessellating its texture cells into quads.
|
|
19230
|
+
*
|
|
19231
|
+
* @param context Canvas 2D context.
|
|
19232
|
+
* @param face Visible projected face.
|
|
19233
|
+
*
|
|
19234
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19235
|
+
*/
|
|
19236
|
+
function drawTexturedProjectedFace(context, face) {
|
|
19237
|
+
var _a;
|
|
19238
|
+
const rows = face.texture.length;
|
|
19239
|
+
const columns = ((_a = face.texture[0]) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
19240
|
+
if (rows === 0 || columns === 0) {
|
|
19241
|
+
return;
|
|
18813
19242
|
}
|
|
18814
|
-
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
|
|
18818
|
-
|
|
18819
|
-
|
|
18820
|
-
|
|
19243
|
+
for (let rowIndex = 0; rowIndex < rows; rowIndex++) {
|
|
19244
|
+
for (let columnIndex = 0; columnIndex < columns; columnIndex++) {
|
|
19245
|
+
const startX = columnIndex / columns;
|
|
19246
|
+
const endX = (columnIndex + 1) / columns;
|
|
19247
|
+
const startY = rowIndex / rows;
|
|
19248
|
+
const endY = (rowIndex + 1) / rows;
|
|
19249
|
+
drawProjectedQuad(context, [
|
|
19250
|
+
interpolateProjectedQuad(face.corners, startX, startY),
|
|
19251
|
+
interpolateProjectedQuad(face.corners, endX, startY),
|
|
19252
|
+
interpolateProjectedQuad(face.corners, endX, endY),
|
|
19253
|
+
interpolateProjectedQuad(face.corners, startX, endY),
|
|
19254
|
+
], face.texture[rowIndex][columnIndex]);
|
|
18821
19255
|
}
|
|
18822
19256
|
}
|
|
18823
|
-
|
|
18824
|
-
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
|
|
18829
|
-
|
|
18830
|
-
|
|
18831
|
-
|
|
18832
|
-
|
|
18833
|
-
|
|
19257
|
+
if (face.lightIntensity > 0) {
|
|
19258
|
+
drawProjectedQuad(context, face.corners, `rgba(255, 255, 255, ${0.15 * face.lightIntensity})`);
|
|
19259
|
+
}
|
|
19260
|
+
else if (face.lightIntensity < 0) {
|
|
19261
|
+
drawProjectedQuad(context, face.corners, `rgba(0, 0, 0, ${0.22 * Math.abs(face.lightIntensity)})`);
|
|
19262
|
+
}
|
|
19263
|
+
context.save();
|
|
19264
|
+
context.beginPath();
|
|
19265
|
+
context.moveTo(face.corners[0].x, face.corners[0].y);
|
|
19266
|
+
for (let cornerIndex = 1; cornerIndex < face.corners.length; cornerIndex++) {
|
|
19267
|
+
context.lineTo(face.corners[cornerIndex].x, face.corners[cornerIndex].y);
|
|
19268
|
+
}
|
|
19269
|
+
context.closePath();
|
|
19270
|
+
context.strokeStyle = face.outlineColor;
|
|
19271
|
+
context.lineWidth = Math.max(1.1, getProjectedQuadPerimeter(face.corners) * 0.0045);
|
|
19272
|
+
context.lineJoin = 'round';
|
|
19273
|
+
context.stroke();
|
|
19274
|
+
context.restore();
|
|
18834
19275
|
}
|
|
18835
19276
|
/**
|
|
18836
|
-
*
|
|
19277
|
+
* Draws one filled projected quad.
|
|
18837
19278
|
*
|
|
18838
|
-
* @param
|
|
18839
|
-
* @param
|
|
18840
|
-
* @
|
|
19279
|
+
* @param context Canvas 2D context.
|
|
19280
|
+
* @param corners Quad corners in clockwise order.
|
|
19281
|
+
* @param fillStyle CSS fill style.
|
|
18841
19282
|
*
|
|
18842
|
-
* @private helper of `
|
|
19283
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
18843
19284
|
*/
|
|
18844
|
-
function
|
|
18845
|
-
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
19285
|
+
function drawProjectedQuad(context, corners, fillStyle) {
|
|
19286
|
+
context.beginPath();
|
|
19287
|
+
context.moveTo(corners[0].x, corners[0].y);
|
|
19288
|
+
context.lineTo(corners[1].x, corners[1].y);
|
|
19289
|
+
context.lineTo(corners[2].x, corners[2].y);
|
|
19290
|
+
context.lineTo(corners[3].x, corners[3].y);
|
|
19291
|
+
context.closePath();
|
|
19292
|
+
context.fillStyle = fillStyle;
|
|
19293
|
+
context.fill();
|
|
19294
|
+
}
|
|
19295
|
+
/**
|
|
19296
|
+
* Interpolates one point inside a projected quad across both quad axes.
|
|
19297
|
+
*
|
|
19298
|
+
* @param corners Quad corners in clockwise order.
|
|
19299
|
+
* @param horizontalRatio Horizontal ratio in the range `[0, 1]`.
|
|
19300
|
+
* @param verticalRatio Vertical ratio in the range `[0, 1]`.
|
|
19301
|
+
* @returns Interpolated projected point.
|
|
19302
|
+
*
|
|
19303
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19304
|
+
*/
|
|
19305
|
+
function interpolateProjectedQuad(corners, horizontalRatio, verticalRatio) {
|
|
19306
|
+
const topPoint = interpolateProjectedPoint(corners[0], corners[1], horizontalRatio);
|
|
19307
|
+
const bottomPoint = interpolateProjectedPoint(corners[3], corners[2], horizontalRatio);
|
|
19308
|
+
return interpolateProjectedPoint(topPoint, bottomPoint, verticalRatio);
|
|
19309
|
+
}
|
|
19310
|
+
/**
|
|
19311
|
+
* Interpolates between two projected points.
|
|
19312
|
+
*
|
|
19313
|
+
* @param startPoint Start point.
|
|
19314
|
+
* @param endPoint End point.
|
|
19315
|
+
* @param ratio Interpolation ratio in the range `[0, 1]`.
|
|
19316
|
+
* @returns Interpolated projected point.
|
|
19317
|
+
*
|
|
19318
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19319
|
+
*/
|
|
19320
|
+
function interpolateProjectedPoint(startPoint, endPoint, ratio) {
|
|
19321
|
+
return {
|
|
19322
|
+
x: startPoint.x + (endPoint.x - startPoint.x) * ratio,
|
|
19323
|
+
y: startPoint.y + (endPoint.y - startPoint.y) * ratio,
|
|
19324
|
+
z: startPoint.z + (endPoint.z - startPoint.z) * ratio,
|
|
19325
|
+
};
|
|
19326
|
+
}
|
|
19327
|
+
/**
|
|
19328
|
+
* Projects one rotated scene point into canvas coordinates.
|
|
19329
|
+
*
|
|
19330
|
+
* @param point Scene point.
|
|
19331
|
+
* @param size Canvas size in CSS pixels.
|
|
19332
|
+
* @param sceneCenterX Horizontal scene center.
|
|
19333
|
+
* @param sceneCenterY Vertical scene center.
|
|
19334
|
+
* @returns Projected point.
|
|
19335
|
+
*
|
|
19336
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19337
|
+
*/
|
|
19338
|
+
function projectScenePoint(point, size, sceneCenterX, sceneCenterY) {
|
|
19339
|
+
const cameraDistance = size * CAMERA_DISTANCE_RATIO;
|
|
19340
|
+
const perspectiveScale = cameraDistance / Math.max(cameraDistance - point.z, cameraDistance * 0.35);
|
|
19341
|
+
return {
|
|
19342
|
+
x: sceneCenterX + point.x * perspectiveScale,
|
|
19343
|
+
y: sceneCenterY + point.y * perspectiveScale,
|
|
19344
|
+
z: point.z,
|
|
19345
|
+
};
|
|
19346
|
+
}
|
|
19347
|
+
/**
|
|
19348
|
+
* Applies the local cuboid rotations and translation to one scene point.
|
|
19349
|
+
*
|
|
19350
|
+
* @param localPoint Point in cuboid-local space.
|
|
19351
|
+
* @param center Cuboid center in scene space.
|
|
19352
|
+
* @param rotationX Cuboid pitch in radians.
|
|
19353
|
+
* @param rotationY Cuboid yaw in radians.
|
|
19354
|
+
* @returns Transformed scene-space point.
|
|
19355
|
+
*
|
|
19356
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19357
|
+
*/
|
|
19358
|
+
function transformScenePoint(localPoint, center, rotationX, rotationY) {
|
|
19359
|
+
const yawedPoint = rotatePointAroundY(localPoint, rotationY);
|
|
19360
|
+
const pitchedPoint = rotatePointAroundX(yawedPoint, rotationX);
|
|
19361
|
+
return {
|
|
19362
|
+
x: center.x + pitchedPoint.x,
|
|
19363
|
+
y: center.y + pitchedPoint.y,
|
|
19364
|
+
z: center.z + pitchedPoint.z,
|
|
19365
|
+
};
|
|
19366
|
+
}
|
|
19367
|
+
/**
|
|
19368
|
+
* Rotates one point around the local Y axis.
|
|
19369
|
+
*
|
|
19370
|
+
* @param point Source point.
|
|
19371
|
+
* @param angle Rotation angle in radians.
|
|
19372
|
+
* @returns Rotated point.
|
|
19373
|
+
*
|
|
19374
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19375
|
+
*/
|
|
19376
|
+
function rotatePointAroundY(point, angle) {
|
|
19377
|
+
const cosine = Math.cos(angle);
|
|
19378
|
+
const sine = Math.sin(angle);
|
|
19379
|
+
return {
|
|
19380
|
+
x: point.x * cosine + point.z * sine,
|
|
19381
|
+
y: point.y,
|
|
19382
|
+
z: -point.x * sine + point.z * cosine,
|
|
19383
|
+
};
|
|
19384
|
+
}
|
|
19385
|
+
/**
|
|
19386
|
+
* Rotates one point around the local X axis.
|
|
19387
|
+
*
|
|
19388
|
+
* @param point Source point.
|
|
19389
|
+
* @param angle Rotation angle in radians.
|
|
19390
|
+
* @returns Rotated point.
|
|
19391
|
+
*
|
|
19392
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19393
|
+
*/
|
|
19394
|
+
function rotatePointAroundX(point, angle) {
|
|
19395
|
+
const cosine = Math.cos(angle);
|
|
19396
|
+
const sine = Math.sin(angle);
|
|
19397
|
+
return {
|
|
19398
|
+
x: point.x,
|
|
19399
|
+
y: point.y * cosine - point.z * sine,
|
|
19400
|
+
z: point.y * sine + point.z * cosine,
|
|
19401
|
+
};
|
|
19402
|
+
}
|
|
19403
|
+
/**
|
|
19404
|
+
* Subtracts one 3D point from another.
|
|
19405
|
+
*
|
|
19406
|
+
* @param leftPoint Left point.
|
|
19407
|
+
* @param rightPoint Right point.
|
|
19408
|
+
* @returns Difference vector.
|
|
19409
|
+
*
|
|
19410
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19411
|
+
*/
|
|
19412
|
+
function subtractPoint3D(leftPoint, rightPoint) {
|
|
19413
|
+
return {
|
|
19414
|
+
x: leftPoint.x - rightPoint.x,
|
|
19415
|
+
y: leftPoint.y - rightPoint.y,
|
|
19416
|
+
z: leftPoint.z - rightPoint.z,
|
|
19417
|
+
};
|
|
19418
|
+
}
|
|
19419
|
+
/**
|
|
19420
|
+
* Computes the 3D cross product of two vectors.
|
|
19421
|
+
*
|
|
19422
|
+
* @param leftVector Left vector.
|
|
19423
|
+
* @param rightVector Right vector.
|
|
19424
|
+
* @returns Cross product.
|
|
19425
|
+
*
|
|
19426
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19427
|
+
*/
|
|
19428
|
+
function crossProduct3D(leftVector, rightVector) {
|
|
19429
|
+
return {
|
|
19430
|
+
x: leftVector.y * rightVector.z - leftVector.z * rightVector.y,
|
|
19431
|
+
y: leftVector.z * rightVector.x - leftVector.x * rightVector.z,
|
|
19432
|
+
z: leftVector.x * rightVector.y - leftVector.y * rightVector.x,
|
|
19433
|
+
};
|
|
19434
|
+
}
|
|
19435
|
+
/**
|
|
19436
|
+
* Computes the 3D dot product of two vectors.
|
|
19437
|
+
*
|
|
19438
|
+
* @param leftVector Left vector.
|
|
19439
|
+
* @param rightVector Right vector.
|
|
19440
|
+
* @returns Dot product.
|
|
19441
|
+
*
|
|
19442
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19443
|
+
*/
|
|
19444
|
+
function dotProduct3D(leftVector, rightVector) {
|
|
19445
|
+
return leftVector.x * rightVector.x + leftVector.y * rightVector.y + leftVector.z * rightVector.z;
|
|
19446
|
+
}
|
|
19447
|
+
/**
|
|
19448
|
+
* Normalizes one 3D vector while keeping zero vectors stable.
|
|
19449
|
+
*
|
|
19450
|
+
* @param vector Source vector.
|
|
19451
|
+
* @returns Normalized vector.
|
|
19452
|
+
*
|
|
19453
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19454
|
+
*/
|
|
19455
|
+
function normalizeVector3(vector) {
|
|
19456
|
+
const length = Math.hypot(vector.x, vector.y, vector.z);
|
|
19457
|
+
if (length === 0) {
|
|
19458
|
+
return vector;
|
|
18851
19459
|
}
|
|
18852
|
-
|
|
18853
|
-
|
|
18854
|
-
|
|
19460
|
+
return {
|
|
19461
|
+
x: vector.x / length,
|
|
19462
|
+
y: vector.y / length,
|
|
19463
|
+
z: vector.z / length,
|
|
19464
|
+
};
|
|
19465
|
+
}
|
|
19466
|
+
/**
|
|
19467
|
+
* Clamps one number into the provided range.
|
|
19468
|
+
*
|
|
19469
|
+
* @param value Input value.
|
|
19470
|
+
* @param minimumValue Inclusive lower bound.
|
|
19471
|
+
* @param maximumValue Inclusive upper bound.
|
|
19472
|
+
* @returns Clamped value.
|
|
19473
|
+
*
|
|
19474
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19475
|
+
*/
|
|
19476
|
+
function clampNumber$1(value, minimumValue, maximumValue) {
|
|
19477
|
+
return Math.min(maximumValue, Math.max(minimumValue, value));
|
|
19478
|
+
}
|
|
19479
|
+
/**
|
|
19480
|
+
* Measures the perimeter of one projected quad.
|
|
19481
|
+
*
|
|
19482
|
+
* @param corners Quad corners.
|
|
19483
|
+
* @returns Perimeter length.
|
|
19484
|
+
*
|
|
19485
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19486
|
+
*/
|
|
19487
|
+
function getProjectedQuadPerimeter(corners) {
|
|
19488
|
+
let perimeter = 0;
|
|
19489
|
+
for (let cornerIndex = 0; cornerIndex < corners.length; cornerIndex++) {
|
|
19490
|
+
const currentCorner = corners[cornerIndex];
|
|
19491
|
+
const nextCorner = corners[(cornerIndex + 1) % corners.length];
|
|
19492
|
+
perimeter += Math.hypot(nextCorner.x - currentCorner.x, nextCorner.y - currentCorner.y);
|
|
18855
19493
|
}
|
|
18856
|
-
|
|
18857
|
-
texture[4][6] = palette.accent;
|
|
18858
|
-
texture[5][2] = palette.highlight;
|
|
18859
|
-
texture[5][5] = palette.highlight;
|
|
18860
|
-
return texture;
|
|
19494
|
+
return perimeter;
|
|
18861
19495
|
}
|
|
18862
19496
|
|
|
18863
19497
|
/* eslint-disable no-magic-numbers */
|
|
@@ -20462,6 +21096,7 @@
|
|
|
20462
21096
|
octopus3AvatarVisual,
|
|
20463
21097
|
asciiOctopusAvatarVisual,
|
|
20464
21098
|
minecraftAvatarVisual,
|
|
21099
|
+
minecraft2AvatarVisual,
|
|
20465
21100
|
fractalAvatarVisual,
|
|
20466
21101
|
orbAvatarVisual,
|
|
20467
21102
|
];
|
|
@@ -22670,7 +23305,10 @@
|
|
|
22670
23305
|
*/
|
|
22671
23306
|
function buildTeamToolDescription(entry) {
|
|
22672
23307
|
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
22673
|
-
return
|
|
23308
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
23309
|
+
Consult teammate ${entry.teammate.label}
|
|
23310
|
+
${block(detailLines.join('\n'))}
|
|
23311
|
+
`);
|
|
22674
23312
|
}
|
|
22675
23313
|
/**
|
|
22676
23314
|
* Collects structured teammate details that should stay visible to the model.
|
|
@@ -28167,7 +28805,10 @@
|
|
|
28167
28805
|
if (hiddenCount > 0) {
|
|
28168
28806
|
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
28169
28807
|
}
|
|
28170
|
-
return
|
|
28808
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
28809
|
+
Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:
|
|
28810
|
+
${block(summaryRows.join('\n'))}
|
|
28811
|
+
`);
|
|
28171
28812
|
}
|
|
28172
28813
|
/**
|
|
28173
28814
|
* Formats one timeout row for assistant-visible timeout listings.
|