@promptbook/remote-server 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 +706 -63
- 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 +705 -62
- 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/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join, basename, dirname, isAbsolute } from 'path';
|
|
1
|
+
import { posix, join, basename, dirname, isAbsolute } from 'path';
|
|
2
2
|
import { spawn } from 'child_process';
|
|
3
3
|
import colors from 'colors';
|
|
4
4
|
import _spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
40
40
|
* @generated
|
|
41
41
|
* @see https://github.com/webgptorg/promptbook
|
|
42
42
|
*/
|
|
43
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
43
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-66';
|
|
44
44
|
/**
|
|
45
45
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
46
46
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -959,6 +959,29 @@ function saturate(amount) {
|
|
|
959
959
|
}
|
|
960
960
|
// TODO: Maybe implement by mix+hsl
|
|
961
961
|
|
|
962
|
+
/**
|
|
963
|
+
* Relative directory name without the `./` prefix for Git ignore rules and glob patterns.
|
|
964
|
+
*
|
|
965
|
+
* @private internal utility for Promptbook-owned temp files
|
|
966
|
+
*/
|
|
967
|
+
const PROMPTBOOK_TEMP_DIRECTORY_NAME = '.promptbook';
|
|
968
|
+
/**
|
|
969
|
+
* Builds one project-relative path inside the shared Promptbook working directory.
|
|
970
|
+
*
|
|
971
|
+
* @private internal utility for Promptbook-owned temp files
|
|
972
|
+
*/
|
|
973
|
+
function getPromptbookTempPath(...pathSegments) {
|
|
974
|
+
return `./${getPromptbookTempPosixPath(...pathSegments)}`;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Builds one POSIX path fragment inside the shared Promptbook working directory for globs and generated text files.
|
|
978
|
+
*
|
|
979
|
+
* @private internal utility for Promptbook-owned temp files
|
|
980
|
+
*/
|
|
981
|
+
function getPromptbookTempPosixPath(...pathSegments) {
|
|
982
|
+
return posix.join(PROMPTBOOK_TEMP_DIRECTORY_NAME, ...pathSegments);
|
|
983
|
+
}
|
|
984
|
+
|
|
962
985
|
/**
|
|
963
986
|
* Returns the same value that is passed as argument.
|
|
964
987
|
* No side effects.
|
|
@@ -1149,7 +1172,6 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐คนโโ๏ธ]
|
|
|
1149
1172
|
*/
|
|
1150
1173
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [๐คนโโ๏ธ]
|
|
1151
1174
|
// <- TODO: [๐] Make also `AGENTS_DIRNAME_ALTERNATIVES`
|
|
1152
|
-
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
1153
1175
|
/**
|
|
1154
1176
|
* Where to store the temporary downloads
|
|
1155
1177
|
*
|
|
@@ -1157,7 +1179,15 @@ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [๐คนโโ๏ธ]
|
|
|
1157
1179
|
*
|
|
1158
1180
|
* @public exported from `@promptbook/core`
|
|
1159
1181
|
*/
|
|
1160
|
-
const DEFAULT_DOWNLOAD_CACHE_DIRNAME = '
|
|
1182
|
+
const DEFAULT_DOWNLOAD_CACHE_DIRNAME = getPromptbookTempPath('download-cache');
|
|
1183
|
+
/**
|
|
1184
|
+
* Where to store the cache of executions for promptbook CLI
|
|
1185
|
+
*
|
|
1186
|
+
* Note: When the folder does not exist, it is created recursively
|
|
1187
|
+
*
|
|
1188
|
+
* @public exported from `@promptbook/core`
|
|
1189
|
+
*/
|
|
1190
|
+
getPromptbookTempPath('execution-cache');
|
|
1161
1191
|
/**
|
|
1162
1192
|
* Where to store the scrape cache
|
|
1163
1193
|
*
|
|
@@ -1165,7 +1195,7 @@ const DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
|
|
|
1165
1195
|
*
|
|
1166
1196
|
* @public exported from `@promptbook/core`
|
|
1167
1197
|
*/
|
|
1168
|
-
const DEFAULT_SCRAPE_CACHE_DIRNAME = '
|
|
1198
|
+
const DEFAULT_SCRAPE_CACHE_DIRNAME = getPromptbookTempPath('scrape-cache');
|
|
1169
1199
|
// <- TODO: [๐งโโ๏ธ]
|
|
1170
1200
|
/**
|
|
1171
1201
|
* Default settings for parsing and generating CSV files in Promptbook.
|
|
@@ -15467,6 +15497,177 @@ function drawFractalCore(context, size, palette, timeMs, corePhase) {
|
|
|
15467
15497
|
context.restore();
|
|
15468
15498
|
}
|
|
15469
15499
|
|
|
15500
|
+
/* eslint-disable no-magic-numbers */
|
|
15501
|
+
/**
|
|
15502
|
+
* Builds the seeded six-face texture pack used by the Minecraft-style head cuboid.
|
|
15503
|
+
*
|
|
15504
|
+
* @param random Seeded random generator.
|
|
15505
|
+
* @param palette Derived avatar palette.
|
|
15506
|
+
* @param hasHeadband Whether the generated avatar should include a colored headband.
|
|
15507
|
+
* @returns Head cuboid textures.
|
|
15508
|
+
*
|
|
15509
|
+
* @private helper of the Minecraft avatar visuals
|
|
15510
|
+
*/
|
|
15511
|
+
function createMinecraftHeadTextures(random, palette, hasHeadband) {
|
|
15512
|
+
const faceTexture = createMinecraftFaceTexture(random, palette, hasHeadband);
|
|
15513
|
+
const hairColor = random() < 0.5 ? palette.primary : palette.secondary;
|
|
15514
|
+
const skinColor = palette.highlight;
|
|
15515
|
+
const headbandColor = hasHeadband ? palette.accent : hairColor;
|
|
15516
|
+
const sideTexture = createFilledTexture(skinColor);
|
|
15517
|
+
const backTexture = createFilledTexture(skinColor);
|
|
15518
|
+
const topTexture = createFilledTexture(hairColor);
|
|
15519
|
+
const bottomTexture = createFilledTexture(`${palette.shadow}cc`);
|
|
15520
|
+
fillTextureRect(sideTexture, 0, 0, 8, 3, hairColor);
|
|
15521
|
+
fillTextureRect(backTexture, 0, 0, 8, 5, hairColor);
|
|
15522
|
+
fillTextureRect(backTexture, 1, 5, 6, 1, hairColor);
|
|
15523
|
+
if (hasHeadband) {
|
|
15524
|
+
fillTextureRect(sideTexture, 0, 2, 8, 1, headbandColor);
|
|
15525
|
+
fillTextureRect(backTexture, 0, 2, 8, 1, headbandColor);
|
|
15526
|
+
fillTextureRect(topTexture, 0, 4, 8, 1, headbandColor);
|
|
15527
|
+
}
|
|
15528
|
+
sideTexture[4][4] = `${palette.shadow}99`;
|
|
15529
|
+
sideTexture[5][4] = `${palette.shadow}cc`;
|
|
15530
|
+
backTexture[6][2] = `${palette.shadow}99`;
|
|
15531
|
+
backTexture[6][5] = `${palette.shadow}99`;
|
|
15532
|
+
return {
|
|
15533
|
+
front: faceTexture,
|
|
15534
|
+
back: backTexture,
|
|
15535
|
+
left: sideTexture,
|
|
15536
|
+
right: mirrorMinecraftTexture(sideTexture),
|
|
15537
|
+
top: topTexture,
|
|
15538
|
+
bottom: bottomTexture,
|
|
15539
|
+
};
|
|
15540
|
+
}
|
|
15541
|
+
/**
|
|
15542
|
+
* Builds the seeded six-face texture pack used by the Minecraft-style torso cuboid.
|
|
15543
|
+
*
|
|
15544
|
+
* @param random Seeded random generator.
|
|
15545
|
+
* @param palette Derived avatar palette.
|
|
15546
|
+
* @returns Torso cuboid textures.
|
|
15547
|
+
*
|
|
15548
|
+
* @private helper of the Minecraft avatar visuals
|
|
15549
|
+
*/
|
|
15550
|
+
function createMinecraftTorsoTextures(random, palette) {
|
|
15551
|
+
const frontTexture = createMinecraftShirtTexture(random, palette);
|
|
15552
|
+
const sideTexture = createFilledTexture(palette.primary);
|
|
15553
|
+
const backTexture = createFilledTexture(palette.primary);
|
|
15554
|
+
const topTexture = createFilledTexture(`${palette.highlight}dd`);
|
|
15555
|
+
const bottomTexture = createFilledTexture(`${palette.shadow}dd`);
|
|
15556
|
+
const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
|
|
15557
|
+
fillTextureRect(sideTexture, 0, 0, 8, 2, palette.shadow);
|
|
15558
|
+
fillTextureRect(backTexture, 0, 0, 8, 2, palette.shadow);
|
|
15559
|
+
fillTextureRect(backTexture, 3, 2, 2, 6, stripeColor);
|
|
15560
|
+
fillTextureRect(sideTexture, 4, 2, 1, 6, stripeColor);
|
|
15561
|
+
fillTextureRect(topTexture, 0, 0, 8, 2, palette.shadow);
|
|
15562
|
+
fillTextureRect(topTexture, 2, 2, 4, 4, stripeColor);
|
|
15563
|
+
return {
|
|
15564
|
+
front: frontTexture,
|
|
15565
|
+
back: backTexture,
|
|
15566
|
+
left: sideTexture,
|
|
15567
|
+
right: mirrorMinecraftTexture(sideTexture),
|
|
15568
|
+
top: topTexture,
|
|
15569
|
+
bottom: bottomTexture,
|
|
15570
|
+
};
|
|
15571
|
+
}
|
|
15572
|
+
/**
|
|
15573
|
+
* Mirrors one Minecraft texture horizontally.
|
|
15574
|
+
*
|
|
15575
|
+
* @param texture Source texture.
|
|
15576
|
+
* @returns Mirrored texture copy.
|
|
15577
|
+
*
|
|
15578
|
+
* @private helper of the Minecraft avatar visuals
|
|
15579
|
+
*/
|
|
15580
|
+
function mirrorMinecraftTexture(texture) {
|
|
15581
|
+
return texture.map((row) => [...row].reverse());
|
|
15582
|
+
}
|
|
15583
|
+
/**
|
|
15584
|
+
* Creates the front-face pixel texture for the cube head.
|
|
15585
|
+
*
|
|
15586
|
+
* @param random Seeded random generator.
|
|
15587
|
+
* @param palette Derived avatar palette.
|
|
15588
|
+
* @param hasHeadband Whether the avatar should render a headband row.
|
|
15589
|
+
* @returns 8x8 pixel texture.
|
|
15590
|
+
*
|
|
15591
|
+
* @private helper of the Minecraft avatar visuals
|
|
15592
|
+
*/
|
|
15593
|
+
function createMinecraftFaceTexture(random, palette, hasHeadband) {
|
|
15594
|
+
const texture = createFilledTexture(palette.highlight);
|
|
15595
|
+
const hairlineColor = random() < 0.5 ? palette.primary : palette.secondary;
|
|
15596
|
+
const cheekColor = random() < 0.5 ? `${palette.accent}bb` : `${palette.secondary}bb`;
|
|
15597
|
+
fillTextureRect(texture, 0, 0, 8, 2, hairlineColor);
|
|
15598
|
+
texture[2][0] = hairlineColor;
|
|
15599
|
+
texture[2][7] = hairlineColor;
|
|
15600
|
+
texture[3][0] = hairlineColor;
|
|
15601
|
+
texture[3][7] = hairlineColor;
|
|
15602
|
+
if (hasHeadband) {
|
|
15603
|
+
fillTextureRect(texture, 0, 2, 8, 1, palette.accent);
|
|
15604
|
+
}
|
|
15605
|
+
texture[3][2] = palette.ink;
|
|
15606
|
+
texture[3][5] = palette.ink;
|
|
15607
|
+
texture[4][2] = '#ffffff';
|
|
15608
|
+
texture[4][5] = '#ffffff';
|
|
15609
|
+
texture[5][1] = cheekColor;
|
|
15610
|
+
texture[5][6] = cheekColor;
|
|
15611
|
+
texture[5][3] = palette.shadow;
|
|
15612
|
+
texture[5][4] = palette.shadow;
|
|
15613
|
+
texture[6][3] = palette.shadow;
|
|
15614
|
+
texture[6][4] = palette.shadow;
|
|
15615
|
+
return texture;
|
|
15616
|
+
}
|
|
15617
|
+
/**
|
|
15618
|
+
* Creates the front-face pixel texture for the torso.
|
|
15619
|
+
*
|
|
15620
|
+
* @param random Seeded random generator.
|
|
15621
|
+
* @param palette Derived avatar palette.
|
|
15622
|
+
* @returns 8x8 torso texture.
|
|
15623
|
+
*
|
|
15624
|
+
* @private helper of the Minecraft avatar visuals
|
|
15625
|
+
*/
|
|
15626
|
+
function createMinecraftShirtTexture(random, palette) {
|
|
15627
|
+
const texture = createFilledTexture(palette.primary);
|
|
15628
|
+
const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
|
|
15629
|
+
fillTextureRect(texture, 0, 0, 8, 2, palette.shadow);
|
|
15630
|
+
for (let rowIndex = 2; rowIndex < 8; rowIndex++) {
|
|
15631
|
+
texture[rowIndex][3] = stripeColor;
|
|
15632
|
+
texture[rowIndex][4] = stripeColor;
|
|
15633
|
+
}
|
|
15634
|
+
texture[4][1] = palette.accent;
|
|
15635
|
+
texture[4][6] = palette.accent;
|
|
15636
|
+
texture[5][2] = palette.highlight;
|
|
15637
|
+
texture[5][5] = palette.highlight;
|
|
15638
|
+
return texture;
|
|
15639
|
+
}
|
|
15640
|
+
/**
|
|
15641
|
+
* Creates one solid-color 8x8 Minecraft texture.
|
|
15642
|
+
*
|
|
15643
|
+
* @param color Fill color.
|
|
15644
|
+
* @returns Filled 8x8 texture.
|
|
15645
|
+
*
|
|
15646
|
+
* @private helper of the Minecraft avatar visuals
|
|
15647
|
+
*/
|
|
15648
|
+
function createFilledTexture(color) {
|
|
15649
|
+
return Array.from({ length: 8 }, () => Array.from({ length: 8 }, () => color));
|
|
15650
|
+
}
|
|
15651
|
+
/**
|
|
15652
|
+
* Fills one rectangular area inside a mutable Minecraft texture.
|
|
15653
|
+
*
|
|
15654
|
+
* @param texture Mutable target texture.
|
|
15655
|
+
* @param x Left texture coordinate.
|
|
15656
|
+
* @param y Top texture coordinate.
|
|
15657
|
+
* @param width Rectangle width.
|
|
15658
|
+
* @param height Rectangle height.
|
|
15659
|
+
* @param color Fill color.
|
|
15660
|
+
*
|
|
15661
|
+
* @private helper of the Minecraft avatar visuals
|
|
15662
|
+
*/
|
|
15663
|
+
function fillTextureRect(texture, x, y, width, height, color) {
|
|
15664
|
+
for (let rowIndex = y; rowIndex < y + height; rowIndex++) {
|
|
15665
|
+
for (let columnIndex = x; columnIndex < x + width; columnIndex++) {
|
|
15666
|
+
texture[rowIndex][columnIndex] = color;
|
|
15667
|
+
}
|
|
15668
|
+
}
|
|
15669
|
+
}
|
|
15670
|
+
|
|
15470
15671
|
/* eslint-disable no-magic-numbers */
|
|
15471
15672
|
/**
|
|
15472
15673
|
* Minecraft-style 3D avatar visual.
|
|
@@ -15491,8 +15692,8 @@ const minecraftAvatarVisual = {
|
|
|
15491
15692
|
const bodyX = size * 0.33;
|
|
15492
15693
|
const bodyY = headY + headSize * 0.96;
|
|
15493
15694
|
const hasHeadband = random() < 0.5;
|
|
15494
|
-
const
|
|
15495
|
-
const
|
|
15695
|
+
const headTextures = createMinecraftHeadTextures(createRandom('minecraft-face'), palette, hasHeadband);
|
|
15696
|
+
const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft-shirt'), palette);
|
|
15496
15697
|
drawAvatarFrame(context, size, palette);
|
|
15497
15698
|
const spotlight = context.createRadialGradient(size * 0.5, size * 0.18, size * 0.05, size * 0.5, size * 0.18, size * 0.5);
|
|
15498
15699
|
spotlight.addColorStop(0, `${palette.highlight}66`);
|
|
@@ -15512,7 +15713,7 @@ const minecraftAvatarVisual = {
|
|
|
15512
15713
|
width: bodyWidth,
|
|
15513
15714
|
height: bodyHeight,
|
|
15514
15715
|
depth: bodyDepth,
|
|
15515
|
-
frontTexture:
|
|
15716
|
+
frontTexture: torsoTextures.front,
|
|
15516
15717
|
topColor: `${palette.highlight}cc`,
|
|
15517
15718
|
sideColor: `${palette.secondary}dd`,
|
|
15518
15719
|
outlineColor: `${palette.shadow}aa`,
|
|
@@ -15523,7 +15724,7 @@ const minecraftAvatarVisual = {
|
|
|
15523
15724
|
width: headSize,
|
|
15524
15725
|
height: headSize,
|
|
15525
15726
|
depth,
|
|
15526
|
-
frontTexture:
|
|
15727
|
+
frontTexture: headTextures.front,
|
|
15527
15728
|
topColor: `${palette.highlight}ee`,
|
|
15528
15729
|
sideColor: `${palette.secondary}ee`,
|
|
15529
15730
|
outlineColor: `${palette.shadow}cc`,
|
|
@@ -15588,72 +15789,505 @@ function drawVoxelCuboid(context, cuboid) {
|
|
|
15588
15789
|
context.closePath();
|
|
15589
15790
|
context.stroke();
|
|
15590
15791
|
}
|
|
15792
|
+
|
|
15793
|
+
/* eslint-disable no-magic-numbers */
|
|
15591
15794
|
/**
|
|
15592
|
-
*
|
|
15795
|
+
* Fixed scene camera distance used for the proper-3D projection.
|
|
15593
15796
|
*
|
|
15594
|
-
* @
|
|
15797
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
15798
|
+
*/
|
|
15799
|
+
const CAMERA_DISTANCE_RATIO = 1.4;
|
|
15800
|
+
/**
|
|
15801
|
+
* Shared light direction used to shade projected cuboid faces.
|
|
15802
|
+
*
|
|
15803
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
15804
|
+
*/
|
|
15805
|
+
const LIGHT_DIRECTION = normalizeVector3({
|
|
15806
|
+
x: 0.4,
|
|
15807
|
+
y: -0.65,
|
|
15808
|
+
z: 0.92,
|
|
15809
|
+
});
|
|
15810
|
+
/**
|
|
15811
|
+
* Minecraft 3D 2 avatar visual.
|
|
15812
|
+
*
|
|
15813
|
+
* @private built-in avatar visual
|
|
15814
|
+
*/
|
|
15815
|
+
const minecraft2AvatarVisual = {
|
|
15816
|
+
id: 'minecraft2',
|
|
15817
|
+
title: 'Minecraft 3D 2',
|
|
15818
|
+
description: 'Proper 3D Minecraft-style portrait with textured cuboids and pointer-driven head turns.',
|
|
15819
|
+
isAnimated: true,
|
|
15820
|
+
supportsPointerTracking: true,
|
|
15821
|
+
render({ context, size, palette, createRandom, timeMs, interaction }) {
|
|
15822
|
+
const spotlightY = size * 0.22;
|
|
15823
|
+
const headRandom = createRandom('minecraft2-head');
|
|
15824
|
+
const hasHeadband = headRandom() < 0.5;
|
|
15825
|
+
const headTextures = createMinecraftHeadTextures(createRandom('minecraft2-head-textures'), palette, hasHeadband);
|
|
15826
|
+
const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft2-body-textures'), palette);
|
|
15827
|
+
const bob = Math.sin(timeMs / 880) * size * 0.014;
|
|
15828
|
+
const bodyYaw = -0.24 + Math.sin(timeMs / 2300) * 0.06 + interaction.bodyOffsetX * 0.16;
|
|
15829
|
+
const bodyPitch = -0.12 + Math.cos(timeMs / 2800) * 0.02 - interaction.bodyOffsetY * 0.06;
|
|
15830
|
+
const headYaw = -0.18 + Math.sin(timeMs / 1900 + 0.6) * 0.05 + interaction.gazeX * 0.62;
|
|
15831
|
+
const headPitch = -0.12 + Math.cos(timeMs / 2400 + 1.1) * 0.03 - interaction.gazeY * 0.38;
|
|
15832
|
+
const sceneCenterX = size * 0.5;
|
|
15833
|
+
const sceneCenterY = size * 0.57;
|
|
15834
|
+
const bodyWidth = size * 0.225;
|
|
15835
|
+
const bodyHeight = size * 0.245;
|
|
15836
|
+
const bodyDepth = size * 0.145;
|
|
15837
|
+
const headSize = size * 0.24;
|
|
15838
|
+
const headLift = size * 0.205;
|
|
15839
|
+
const headForwardShift = interaction.intensity * size * 0.018;
|
|
15840
|
+
const sceneCuboids = [
|
|
15841
|
+
{
|
|
15842
|
+
center: {
|
|
15843
|
+
x: interaction.bodyOffsetX * size * 0.026,
|
|
15844
|
+
y: size * 0.05 + interaction.bodyOffsetY * size * 0.018 + bob,
|
|
15845
|
+
z: 0,
|
|
15846
|
+
},
|
|
15847
|
+
width: bodyWidth,
|
|
15848
|
+
height: bodyHeight,
|
|
15849
|
+
depth: bodyDepth,
|
|
15850
|
+
rotationX: bodyPitch,
|
|
15851
|
+
rotationY: bodyYaw,
|
|
15852
|
+
textures: torsoTextures,
|
|
15853
|
+
outlineColor: `${palette.shadow}cc`,
|
|
15854
|
+
},
|
|
15855
|
+
{
|
|
15856
|
+
center: {
|
|
15857
|
+
x: interaction.bodyOffsetX * size * 0.018 + interaction.gazeX * size * 0.016,
|
|
15858
|
+
y: -headLift + bob * 1.15,
|
|
15859
|
+
z: headForwardShift,
|
|
15860
|
+
},
|
|
15861
|
+
width: headSize,
|
|
15862
|
+
height: headSize,
|
|
15863
|
+
depth: headSize,
|
|
15864
|
+
rotationX: headPitch,
|
|
15865
|
+
rotationY: headYaw,
|
|
15866
|
+
textures: headTextures,
|
|
15867
|
+
outlineColor: `${palette.shadow}dd`,
|
|
15868
|
+
},
|
|
15869
|
+
];
|
|
15870
|
+
const visibleFaces = sceneCuboids
|
|
15871
|
+
.flatMap((cuboid) => resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY))
|
|
15872
|
+
.sort((firstFace, secondFace) => firstFace.averageDepth - secondFace.averageDepth);
|
|
15873
|
+
drawAvatarFrame(context, size, palette);
|
|
15874
|
+
drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs);
|
|
15875
|
+
drawMinecraftShadow(context, size, palette, interaction, timeMs);
|
|
15876
|
+
for (const visibleFace of visibleFaces) {
|
|
15877
|
+
drawTexturedProjectedFace(context, visibleFace);
|
|
15878
|
+
}
|
|
15879
|
+
},
|
|
15880
|
+
};
|
|
15881
|
+
/**
|
|
15882
|
+
* Draws the shared background atmosphere behind the Minecraft 3D 2 portrait.
|
|
15883
|
+
*
|
|
15884
|
+
* @param context Canvas 2D context.
|
|
15885
|
+
* @param size Canvas size in CSS pixels.
|
|
15595
15886
|
* @param palette Derived avatar palette.
|
|
15596
|
-
* @param
|
|
15597
|
-
* @
|
|
15887
|
+
* @param sceneCenterX Horizontal scene center.
|
|
15888
|
+
* @param spotlightY Vertical spotlight anchor.
|
|
15889
|
+
* @param interaction Smoothed pointer-aware interaction state.
|
|
15890
|
+
* @param timeMs Current animation time in milliseconds.
|
|
15598
15891
|
*
|
|
15599
|
-
* @private helper of `
|
|
15892
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
15600
15893
|
*/
|
|
15601
|
-
function
|
|
15602
|
-
const
|
|
15603
|
-
|
|
15604
|
-
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15894
|
+
function drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs) {
|
|
15895
|
+
const spotlightGradient = context.createRadialGradient(sceneCenterX + interaction.gazeX * size * 0.08, spotlightY + interaction.gazeY * size * 0.05, size * 0.03, sceneCenterX, spotlightY, size * 0.52);
|
|
15896
|
+
spotlightGradient.addColorStop(0, `${palette.highlight}66`);
|
|
15897
|
+
spotlightGradient.addColorStop(0.42, `${palette.accent}1d`);
|
|
15898
|
+
spotlightGradient.addColorStop(1, `${palette.highlight}00`);
|
|
15899
|
+
context.fillStyle = spotlightGradient;
|
|
15900
|
+
context.fillRect(0, 0, size, size);
|
|
15901
|
+
const rimGradient = context.createLinearGradient(0, size * 0.14, 0, size * 0.92);
|
|
15902
|
+
rimGradient.addColorStop(0, `${palette.highlight}12`);
|
|
15903
|
+
rimGradient.addColorStop(0.55, `${palette.secondary}0a`);
|
|
15904
|
+
rimGradient.addColorStop(1, `${palette.shadow}00`);
|
|
15905
|
+
context.fillStyle = rimGradient;
|
|
15906
|
+
context.fillRect(0, 0, size, size);
|
|
15907
|
+
context.save();
|
|
15908
|
+
context.globalAlpha = 0.08 + interaction.intensity * 0.04;
|
|
15909
|
+
context.fillStyle = palette.highlight;
|
|
15910
|
+
context.beginPath();
|
|
15911
|
+
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);
|
|
15912
|
+
context.fill();
|
|
15913
|
+
context.restore();
|
|
15914
|
+
}
|
|
15915
|
+
/**
|
|
15916
|
+
* Draws the soft floor shadow used to anchor the cuboids in the frame.
|
|
15917
|
+
*
|
|
15918
|
+
* @param context Canvas 2D context.
|
|
15919
|
+
* @param size Canvas size in CSS pixels.
|
|
15920
|
+
* @param palette Derived avatar palette.
|
|
15921
|
+
* @param interaction Smoothed pointer-aware interaction state.
|
|
15922
|
+
* @param timeMs Current animation time in milliseconds.
|
|
15923
|
+
*
|
|
15924
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
15925
|
+
*/
|
|
15926
|
+
function drawMinecraftShadow(context, size, palette, interaction, timeMs) {
|
|
15927
|
+
context.save();
|
|
15928
|
+
context.fillStyle = `${palette.shadow}66`;
|
|
15929
|
+
context.filter = `blur(${size * 0.02}px)`;
|
|
15930
|
+
context.beginPath();
|
|
15931
|
+
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);
|
|
15932
|
+
context.fill();
|
|
15933
|
+
context.restore();
|
|
15934
|
+
}
|
|
15935
|
+
/**
|
|
15936
|
+
* Resolves all visible projected faces for one scene cuboid.
|
|
15937
|
+
*
|
|
15938
|
+
* @param cuboid Scene cuboid definition.
|
|
15939
|
+
* @param size Canvas size in CSS pixels.
|
|
15940
|
+
* @param sceneCenterX Horizontal scene center.
|
|
15941
|
+
* @param sceneCenterY Vertical scene center.
|
|
15942
|
+
* @returns Visible faces sorted later by depth.
|
|
15943
|
+
*
|
|
15944
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
15945
|
+
*/
|
|
15946
|
+
function resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY) {
|
|
15947
|
+
const halfWidth = cuboid.width / 2;
|
|
15948
|
+
const halfHeight = cuboid.height / 2;
|
|
15949
|
+
const halfDepth = cuboid.depth / 2;
|
|
15950
|
+
const faceDefinitions = [
|
|
15951
|
+
{
|
|
15952
|
+
texture: cuboid.textures.front,
|
|
15953
|
+
corners: [
|
|
15954
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
15955
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
15956
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
15957
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
15958
|
+
],
|
|
15959
|
+
},
|
|
15960
|
+
{
|
|
15961
|
+
texture: cuboid.textures.back,
|
|
15962
|
+
corners: [
|
|
15963
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
15964
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
15965
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
15966
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
15967
|
+
],
|
|
15968
|
+
},
|
|
15969
|
+
{
|
|
15970
|
+
texture: cuboid.textures.right,
|
|
15971
|
+
corners: [
|
|
15972
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
15973
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
15974
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
15975
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
15976
|
+
],
|
|
15977
|
+
},
|
|
15978
|
+
{
|
|
15979
|
+
texture: cuboid.textures.left,
|
|
15980
|
+
corners: [
|
|
15981
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
15982
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
15983
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
15984
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
15985
|
+
],
|
|
15986
|
+
},
|
|
15987
|
+
{
|
|
15988
|
+
texture: cuboid.textures.top,
|
|
15989
|
+
corners: [
|
|
15990
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
15991
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
15992
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
15993
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
15994
|
+
],
|
|
15995
|
+
},
|
|
15996
|
+
{
|
|
15997
|
+
texture: cuboid.textures.bottom,
|
|
15998
|
+
corners: [
|
|
15999
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
16000
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
16001
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
16002
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
16003
|
+
],
|
|
16004
|
+
},
|
|
16005
|
+
];
|
|
16006
|
+
const visibleFaces = faceDefinitions
|
|
16007
|
+
.map((faceDefinition) => {
|
|
16008
|
+
const transformedCorners = faceDefinition.corners.map((corner) => transformScenePoint(corner, cuboid.center, cuboid.rotationX, cuboid.rotationY));
|
|
16009
|
+
const faceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
|
|
16010
|
+
if (faceNormal.z <= 0.02) {
|
|
16011
|
+
return null;
|
|
15608
16012
|
}
|
|
16013
|
+
const projectedCorners = transformedCorners.map((corner) => projectScenePoint(corner, size, sceneCenterX, sceneCenterY));
|
|
16014
|
+
return {
|
|
16015
|
+
corners: projectedCorners,
|
|
16016
|
+
texture: faceDefinition.texture,
|
|
16017
|
+
averageDepth: transformedCorners.reduce((depthSum, corner) => depthSum + corner.z, 0) / transformedCorners.length,
|
|
16018
|
+
lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION), -1, 1),
|
|
16019
|
+
outlineColor: cuboid.outlineColor,
|
|
16020
|
+
};
|
|
16021
|
+
});
|
|
16022
|
+
return visibleFaces.filter((visibleFace) => visibleFace !== null);
|
|
16023
|
+
}
|
|
16024
|
+
/**
|
|
16025
|
+
* Draws one projected textured face by tessellating its texture cells into quads.
|
|
16026
|
+
*
|
|
16027
|
+
* @param context Canvas 2D context.
|
|
16028
|
+
* @param face Visible projected face.
|
|
16029
|
+
*
|
|
16030
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16031
|
+
*/
|
|
16032
|
+
function drawTexturedProjectedFace(context, face) {
|
|
16033
|
+
var _a;
|
|
16034
|
+
const rows = face.texture.length;
|
|
16035
|
+
const columns = ((_a = face.texture[0]) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
16036
|
+
if (rows === 0 || columns === 0) {
|
|
16037
|
+
return;
|
|
15609
16038
|
}
|
|
15610
|
-
|
|
15611
|
-
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15615
|
-
|
|
15616
|
-
|
|
16039
|
+
for (let rowIndex = 0; rowIndex < rows; rowIndex++) {
|
|
16040
|
+
for (let columnIndex = 0; columnIndex < columns; columnIndex++) {
|
|
16041
|
+
const startX = columnIndex / columns;
|
|
16042
|
+
const endX = (columnIndex + 1) / columns;
|
|
16043
|
+
const startY = rowIndex / rows;
|
|
16044
|
+
const endY = (rowIndex + 1) / rows;
|
|
16045
|
+
drawProjectedQuad(context, [
|
|
16046
|
+
interpolateProjectedQuad(face.corners, startX, startY),
|
|
16047
|
+
interpolateProjectedQuad(face.corners, endX, startY),
|
|
16048
|
+
interpolateProjectedQuad(face.corners, endX, endY),
|
|
16049
|
+
interpolateProjectedQuad(face.corners, startX, endY),
|
|
16050
|
+
], face.texture[rowIndex][columnIndex]);
|
|
15617
16051
|
}
|
|
15618
16052
|
}
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
|
|
16053
|
+
if (face.lightIntensity > 0) {
|
|
16054
|
+
drawProjectedQuad(context, face.corners, `rgba(255, 255, 255, ${0.15 * face.lightIntensity})`);
|
|
16055
|
+
}
|
|
16056
|
+
else if (face.lightIntensity < 0) {
|
|
16057
|
+
drawProjectedQuad(context, face.corners, `rgba(0, 0, 0, ${0.22 * Math.abs(face.lightIntensity)})`);
|
|
16058
|
+
}
|
|
16059
|
+
context.save();
|
|
16060
|
+
context.beginPath();
|
|
16061
|
+
context.moveTo(face.corners[0].x, face.corners[0].y);
|
|
16062
|
+
for (let cornerIndex = 1; cornerIndex < face.corners.length; cornerIndex++) {
|
|
16063
|
+
context.lineTo(face.corners[cornerIndex].x, face.corners[cornerIndex].y);
|
|
16064
|
+
}
|
|
16065
|
+
context.closePath();
|
|
16066
|
+
context.strokeStyle = face.outlineColor;
|
|
16067
|
+
context.lineWidth = Math.max(1.1, getProjectedQuadPerimeter(face.corners) * 0.0045);
|
|
16068
|
+
context.lineJoin = 'round';
|
|
16069
|
+
context.stroke();
|
|
16070
|
+
context.restore();
|
|
15630
16071
|
}
|
|
15631
16072
|
/**
|
|
15632
|
-
*
|
|
16073
|
+
* Draws one filled projected quad.
|
|
15633
16074
|
*
|
|
15634
|
-
* @param
|
|
15635
|
-
* @param
|
|
15636
|
-
* @
|
|
16075
|
+
* @param context Canvas 2D context.
|
|
16076
|
+
* @param corners Quad corners in clockwise order.
|
|
16077
|
+
* @param fillStyle CSS fill style.
|
|
15637
16078
|
*
|
|
15638
|
-
* @private helper of `
|
|
16079
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
15639
16080
|
*/
|
|
15640
|
-
function
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
|
|
15646
|
-
|
|
16081
|
+
function drawProjectedQuad(context, corners, fillStyle) {
|
|
16082
|
+
context.beginPath();
|
|
16083
|
+
context.moveTo(corners[0].x, corners[0].y);
|
|
16084
|
+
context.lineTo(corners[1].x, corners[1].y);
|
|
16085
|
+
context.lineTo(corners[2].x, corners[2].y);
|
|
16086
|
+
context.lineTo(corners[3].x, corners[3].y);
|
|
16087
|
+
context.closePath();
|
|
16088
|
+
context.fillStyle = fillStyle;
|
|
16089
|
+
context.fill();
|
|
16090
|
+
}
|
|
16091
|
+
/**
|
|
16092
|
+
* Interpolates one point inside a projected quad across both quad axes.
|
|
16093
|
+
*
|
|
16094
|
+
* @param corners Quad corners in clockwise order.
|
|
16095
|
+
* @param horizontalRatio Horizontal ratio in the range `[0, 1]`.
|
|
16096
|
+
* @param verticalRatio Vertical ratio in the range `[0, 1]`.
|
|
16097
|
+
* @returns Interpolated projected point.
|
|
16098
|
+
*
|
|
16099
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16100
|
+
*/
|
|
16101
|
+
function interpolateProjectedQuad(corners, horizontalRatio, verticalRatio) {
|
|
16102
|
+
const topPoint = interpolateProjectedPoint(corners[0], corners[1], horizontalRatio);
|
|
16103
|
+
const bottomPoint = interpolateProjectedPoint(corners[3], corners[2], horizontalRatio);
|
|
16104
|
+
return interpolateProjectedPoint(topPoint, bottomPoint, verticalRatio);
|
|
16105
|
+
}
|
|
16106
|
+
/**
|
|
16107
|
+
* Interpolates between two projected points.
|
|
16108
|
+
*
|
|
16109
|
+
* @param startPoint Start point.
|
|
16110
|
+
* @param endPoint End point.
|
|
16111
|
+
* @param ratio Interpolation ratio in the range `[0, 1]`.
|
|
16112
|
+
* @returns Interpolated projected point.
|
|
16113
|
+
*
|
|
16114
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16115
|
+
*/
|
|
16116
|
+
function interpolateProjectedPoint(startPoint, endPoint, ratio) {
|
|
16117
|
+
return {
|
|
16118
|
+
x: startPoint.x + (endPoint.x - startPoint.x) * ratio,
|
|
16119
|
+
y: startPoint.y + (endPoint.y - startPoint.y) * ratio,
|
|
16120
|
+
z: startPoint.z + (endPoint.z - startPoint.z) * ratio,
|
|
16121
|
+
};
|
|
16122
|
+
}
|
|
16123
|
+
/**
|
|
16124
|
+
* Projects one rotated scene point into canvas coordinates.
|
|
16125
|
+
*
|
|
16126
|
+
* @param point Scene point.
|
|
16127
|
+
* @param size Canvas size in CSS pixels.
|
|
16128
|
+
* @param sceneCenterX Horizontal scene center.
|
|
16129
|
+
* @param sceneCenterY Vertical scene center.
|
|
16130
|
+
* @returns Projected point.
|
|
16131
|
+
*
|
|
16132
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16133
|
+
*/
|
|
16134
|
+
function projectScenePoint(point, size, sceneCenterX, sceneCenterY) {
|
|
16135
|
+
const cameraDistance = size * CAMERA_DISTANCE_RATIO;
|
|
16136
|
+
const perspectiveScale = cameraDistance / Math.max(cameraDistance - point.z, cameraDistance * 0.35);
|
|
16137
|
+
return {
|
|
16138
|
+
x: sceneCenterX + point.x * perspectiveScale,
|
|
16139
|
+
y: sceneCenterY + point.y * perspectiveScale,
|
|
16140
|
+
z: point.z,
|
|
16141
|
+
};
|
|
16142
|
+
}
|
|
16143
|
+
/**
|
|
16144
|
+
* Applies the local cuboid rotations and translation to one scene point.
|
|
16145
|
+
*
|
|
16146
|
+
* @param localPoint Point in cuboid-local space.
|
|
16147
|
+
* @param center Cuboid center in scene space.
|
|
16148
|
+
* @param rotationX Cuboid pitch in radians.
|
|
16149
|
+
* @param rotationY Cuboid yaw in radians.
|
|
16150
|
+
* @returns Transformed scene-space point.
|
|
16151
|
+
*
|
|
16152
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16153
|
+
*/
|
|
16154
|
+
function transformScenePoint(localPoint, center, rotationX, rotationY) {
|
|
16155
|
+
const yawedPoint = rotatePointAroundY(localPoint, rotationY);
|
|
16156
|
+
const pitchedPoint = rotatePointAroundX(yawedPoint, rotationX);
|
|
16157
|
+
return {
|
|
16158
|
+
x: center.x + pitchedPoint.x,
|
|
16159
|
+
y: center.y + pitchedPoint.y,
|
|
16160
|
+
z: center.z + pitchedPoint.z,
|
|
16161
|
+
};
|
|
16162
|
+
}
|
|
16163
|
+
/**
|
|
16164
|
+
* Rotates one point around the local Y axis.
|
|
16165
|
+
*
|
|
16166
|
+
* @param point Source point.
|
|
16167
|
+
* @param angle Rotation angle in radians.
|
|
16168
|
+
* @returns Rotated point.
|
|
16169
|
+
*
|
|
16170
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16171
|
+
*/
|
|
16172
|
+
function rotatePointAroundY(point, angle) {
|
|
16173
|
+
const cosine = Math.cos(angle);
|
|
16174
|
+
const sine = Math.sin(angle);
|
|
16175
|
+
return {
|
|
16176
|
+
x: point.x * cosine + point.z * sine,
|
|
16177
|
+
y: point.y,
|
|
16178
|
+
z: -point.x * sine + point.z * cosine,
|
|
16179
|
+
};
|
|
16180
|
+
}
|
|
16181
|
+
/**
|
|
16182
|
+
* Rotates one point around the local X axis.
|
|
16183
|
+
*
|
|
16184
|
+
* @param point Source point.
|
|
16185
|
+
* @param angle Rotation angle in radians.
|
|
16186
|
+
* @returns Rotated point.
|
|
16187
|
+
*
|
|
16188
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16189
|
+
*/
|
|
16190
|
+
function rotatePointAroundX(point, angle) {
|
|
16191
|
+
const cosine = Math.cos(angle);
|
|
16192
|
+
const sine = Math.sin(angle);
|
|
16193
|
+
return {
|
|
16194
|
+
x: point.x,
|
|
16195
|
+
y: point.y * cosine - point.z * sine,
|
|
16196
|
+
z: point.y * sine + point.z * cosine,
|
|
16197
|
+
};
|
|
16198
|
+
}
|
|
16199
|
+
/**
|
|
16200
|
+
* Subtracts one 3D point from another.
|
|
16201
|
+
*
|
|
16202
|
+
* @param leftPoint Left point.
|
|
16203
|
+
* @param rightPoint Right point.
|
|
16204
|
+
* @returns Difference vector.
|
|
16205
|
+
*
|
|
16206
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16207
|
+
*/
|
|
16208
|
+
function subtractPoint3D(leftPoint, rightPoint) {
|
|
16209
|
+
return {
|
|
16210
|
+
x: leftPoint.x - rightPoint.x,
|
|
16211
|
+
y: leftPoint.y - rightPoint.y,
|
|
16212
|
+
z: leftPoint.z - rightPoint.z,
|
|
16213
|
+
};
|
|
16214
|
+
}
|
|
16215
|
+
/**
|
|
16216
|
+
* Computes the 3D cross product of two vectors.
|
|
16217
|
+
*
|
|
16218
|
+
* @param leftVector Left vector.
|
|
16219
|
+
* @param rightVector Right vector.
|
|
16220
|
+
* @returns Cross product.
|
|
16221
|
+
*
|
|
16222
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16223
|
+
*/
|
|
16224
|
+
function crossProduct3D(leftVector, rightVector) {
|
|
16225
|
+
return {
|
|
16226
|
+
x: leftVector.y * rightVector.z - leftVector.z * rightVector.y,
|
|
16227
|
+
y: leftVector.z * rightVector.x - leftVector.x * rightVector.z,
|
|
16228
|
+
z: leftVector.x * rightVector.y - leftVector.y * rightVector.x,
|
|
16229
|
+
};
|
|
16230
|
+
}
|
|
16231
|
+
/**
|
|
16232
|
+
* Computes the 3D dot product of two vectors.
|
|
16233
|
+
*
|
|
16234
|
+
* @param leftVector Left vector.
|
|
16235
|
+
* @param rightVector Right vector.
|
|
16236
|
+
* @returns Dot product.
|
|
16237
|
+
*
|
|
16238
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16239
|
+
*/
|
|
16240
|
+
function dotProduct3D(leftVector, rightVector) {
|
|
16241
|
+
return leftVector.x * rightVector.x + leftVector.y * rightVector.y + leftVector.z * rightVector.z;
|
|
16242
|
+
}
|
|
16243
|
+
/**
|
|
16244
|
+
* Normalizes one 3D vector while keeping zero vectors stable.
|
|
16245
|
+
*
|
|
16246
|
+
* @param vector Source vector.
|
|
16247
|
+
* @returns Normalized vector.
|
|
16248
|
+
*
|
|
16249
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16250
|
+
*/
|
|
16251
|
+
function normalizeVector3(vector) {
|
|
16252
|
+
const length = Math.hypot(vector.x, vector.y, vector.z);
|
|
16253
|
+
if (length === 0) {
|
|
16254
|
+
return vector;
|
|
15647
16255
|
}
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
16256
|
+
return {
|
|
16257
|
+
x: vector.x / length,
|
|
16258
|
+
y: vector.y / length,
|
|
16259
|
+
z: vector.z / length,
|
|
16260
|
+
};
|
|
16261
|
+
}
|
|
16262
|
+
/**
|
|
16263
|
+
* Clamps one number into the provided range.
|
|
16264
|
+
*
|
|
16265
|
+
* @param value Input value.
|
|
16266
|
+
* @param minimumValue Inclusive lower bound.
|
|
16267
|
+
* @param maximumValue Inclusive upper bound.
|
|
16268
|
+
* @returns Clamped value.
|
|
16269
|
+
*
|
|
16270
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16271
|
+
*/
|
|
16272
|
+
function clampNumber$1(value, minimumValue, maximumValue) {
|
|
16273
|
+
return Math.min(maximumValue, Math.max(minimumValue, value));
|
|
16274
|
+
}
|
|
16275
|
+
/**
|
|
16276
|
+
* Measures the perimeter of one projected quad.
|
|
16277
|
+
*
|
|
16278
|
+
* @param corners Quad corners.
|
|
16279
|
+
* @returns Perimeter length.
|
|
16280
|
+
*
|
|
16281
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
16282
|
+
*/
|
|
16283
|
+
function getProjectedQuadPerimeter(corners) {
|
|
16284
|
+
let perimeter = 0;
|
|
16285
|
+
for (let cornerIndex = 0; cornerIndex < corners.length; cornerIndex++) {
|
|
16286
|
+
const currentCorner = corners[cornerIndex];
|
|
16287
|
+
const nextCorner = corners[(cornerIndex + 1) % corners.length];
|
|
16288
|
+
perimeter += Math.hypot(nextCorner.x - currentCorner.x, nextCorner.y - currentCorner.y);
|
|
15651
16289
|
}
|
|
15652
|
-
|
|
15653
|
-
texture[4][6] = palette.accent;
|
|
15654
|
-
texture[5][2] = palette.highlight;
|
|
15655
|
-
texture[5][5] = palette.highlight;
|
|
15656
|
-
return texture;
|
|
16290
|
+
return perimeter;
|
|
15657
16291
|
}
|
|
15658
16292
|
|
|
15659
16293
|
/* eslint-disable no-magic-numbers */
|
|
@@ -17258,6 +17892,7 @@ const AVATAR_VISUALS = [
|
|
|
17258
17892
|
octopus3AvatarVisual,
|
|
17259
17893
|
asciiOctopusAvatarVisual,
|
|
17260
17894
|
minecraftAvatarVisual,
|
|
17895
|
+
minecraft2AvatarVisual,
|
|
17261
17896
|
fractalAvatarVisual,
|
|
17262
17897
|
orbAvatarVisual,
|
|
17263
17898
|
];
|
|
@@ -19466,7 +20101,10 @@ function buildTeamSystemMessageBody(teamEntries) {
|
|
|
19466
20101
|
*/
|
|
19467
20102
|
function buildTeamToolDescription(entry) {
|
|
19468
20103
|
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
19469
|
-
return
|
|
20104
|
+
return spaceTrim$1((block) => `
|
|
20105
|
+
Consult teammate ${entry.teammate.label}
|
|
20106
|
+
${block(detailLines.join('\n'))}
|
|
20107
|
+
`);
|
|
19470
20108
|
}
|
|
19471
20109
|
/**
|
|
19472
20110
|
* Collects structured teammate details that should stay visible to the model.
|
|
@@ -24963,7 +25601,10 @@ function createListedTimeoutsAssistantMessage(options) {
|
|
|
24963
25601
|
if (hiddenCount > 0) {
|
|
24964
25602
|
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
24965
25603
|
}
|
|
24966
|
-
return
|
|
25604
|
+
return spaceTrim$1((block) => `
|
|
25605
|
+
Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:
|
|
25606
|
+
${block(summaryRows.join('\n'))}
|
|
25607
|
+
`);
|
|
24967
25608
|
}
|
|
24968
25609
|
/**
|
|
24969
25610
|
* Formats one timeout row for assistant-visible timeout listings.
|
|
@@ -27932,8 +28573,10 @@ async function renderMarkdownServerIndex(runtime) {
|
|
|
27932
28573
|
**Application mode:** ${serverInfo.isApplicationModeAllowed ? 'enabled' : 'disabled'}
|
|
27933
28574
|
${block(!runtime.configuration.isApplicationModeAllowed || runtime.configuration.collection === null
|
|
27934
28575
|
? ''
|
|
27935
|
-
:
|
|
27936
|
-
|
|
28576
|
+
: spaceTrim$1((nestedBlock) => `
|
|
28577
|
+
**Pipelines in collection:**
|
|
28578
|
+
${nestedBlock(serverInfo.pipelines.map((pipelineUrl) => `- ${pipelineUrl}`).join('\n'))}
|
|
28579
|
+
`))}
|
|
27937
28580
|
**Running executions:** ${serverInfo.runningExecutions}
|
|
27938
28581
|
|
|
27939
28582
|
---
|