@promptbook/wizard 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 +695 -62
- 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 +694 -61
- 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
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
* @generated
|
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
|
51
51
|
*/
|
|
52
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
52
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-66';
|
|
53
53
|
/**
|
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
55
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -982,6 +982,29 @@
|
|
|
982
982
|
}
|
|
983
983
|
// TODO: Maybe implement by mix+hsl
|
|
984
984
|
|
|
985
|
+
/**
|
|
986
|
+
* Relative directory name without the `./` prefix for Git ignore rules and glob patterns.
|
|
987
|
+
*
|
|
988
|
+
* @private internal utility for Promptbook-owned temp files
|
|
989
|
+
*/
|
|
990
|
+
const PROMPTBOOK_TEMP_DIRECTORY_NAME = '.promptbook';
|
|
991
|
+
/**
|
|
992
|
+
* Builds one project-relative path inside the shared Promptbook working directory.
|
|
993
|
+
*
|
|
994
|
+
* @private internal utility for Promptbook-owned temp files
|
|
995
|
+
*/
|
|
996
|
+
function getPromptbookTempPath(...pathSegments) {
|
|
997
|
+
return `./${getPromptbookTempPosixPath(...pathSegments)}`;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Builds one POSIX path fragment inside the shared Promptbook working directory for globs and generated text files.
|
|
1001
|
+
*
|
|
1002
|
+
* @private internal utility for Promptbook-owned temp files
|
|
1003
|
+
*/
|
|
1004
|
+
function getPromptbookTempPosixPath(...pathSegments) {
|
|
1005
|
+
return path.posix.join(PROMPTBOOK_TEMP_DIRECTORY_NAME, ...pathSegments);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
985
1008
|
/**
|
|
986
1009
|
* Returns the same value that is passed as argument.
|
|
987
1010
|
* No side effects.
|
|
@@ -1196,7 +1219,6 @@
|
|
|
1196
1219
|
*/
|
|
1197
1220
|
const DEFAULT_BOOKS_DIRNAME = './books';
|
|
1198
1221
|
// <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
|
|
1199
|
-
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
1200
1222
|
/**
|
|
1201
1223
|
* Where to store the temporary downloads
|
|
1202
1224
|
*
|
|
@@ -1204,7 +1226,7 @@
|
|
|
1204
1226
|
*
|
|
1205
1227
|
* @public exported from `@promptbook/core`
|
|
1206
1228
|
*/
|
|
1207
|
-
const DEFAULT_DOWNLOAD_CACHE_DIRNAME = '
|
|
1229
|
+
const DEFAULT_DOWNLOAD_CACHE_DIRNAME = getPromptbookTempPath('download-cache');
|
|
1208
1230
|
/**
|
|
1209
1231
|
* Where to store the cache of executions for promptbook CLI
|
|
1210
1232
|
*
|
|
@@ -1212,7 +1234,7 @@
|
|
|
1212
1234
|
*
|
|
1213
1235
|
* @public exported from `@promptbook/core`
|
|
1214
1236
|
*/
|
|
1215
|
-
const DEFAULT_EXECUTION_CACHE_DIRNAME = '
|
|
1237
|
+
const DEFAULT_EXECUTION_CACHE_DIRNAME = getPromptbookTempPath('execution-cache');
|
|
1216
1238
|
/**
|
|
1217
1239
|
* Where to store the scrape cache
|
|
1218
1240
|
*
|
|
@@ -1220,7 +1242,7 @@
|
|
|
1220
1242
|
*
|
|
1221
1243
|
* @public exported from `@promptbook/core`
|
|
1222
1244
|
*/
|
|
1223
|
-
const DEFAULT_SCRAPE_CACHE_DIRNAME = '
|
|
1245
|
+
const DEFAULT_SCRAPE_CACHE_DIRNAME = getPromptbookTempPath('scrape-cache');
|
|
1224
1246
|
/*
|
|
1225
1247
|
TODO: [🌃]
|
|
1226
1248
|
/**
|
|
@@ -23412,6 +23434,177 @@
|
|
|
23412
23434
|
context.restore();
|
|
23413
23435
|
}
|
|
23414
23436
|
|
|
23437
|
+
/* eslint-disable no-magic-numbers */
|
|
23438
|
+
/**
|
|
23439
|
+
* Builds the seeded six-face texture pack used by the Minecraft-style head cuboid.
|
|
23440
|
+
*
|
|
23441
|
+
* @param random Seeded random generator.
|
|
23442
|
+
* @param palette Derived avatar palette.
|
|
23443
|
+
* @param hasHeadband Whether the generated avatar should include a colored headband.
|
|
23444
|
+
* @returns Head cuboid textures.
|
|
23445
|
+
*
|
|
23446
|
+
* @private helper of the Minecraft avatar visuals
|
|
23447
|
+
*/
|
|
23448
|
+
function createMinecraftHeadTextures(random, palette, hasHeadband) {
|
|
23449
|
+
const faceTexture = createMinecraftFaceTexture(random, palette, hasHeadband);
|
|
23450
|
+
const hairColor = random() < 0.5 ? palette.primary : palette.secondary;
|
|
23451
|
+
const skinColor = palette.highlight;
|
|
23452
|
+
const headbandColor = hasHeadband ? palette.accent : hairColor;
|
|
23453
|
+
const sideTexture = createFilledTexture(skinColor);
|
|
23454
|
+
const backTexture = createFilledTexture(skinColor);
|
|
23455
|
+
const topTexture = createFilledTexture(hairColor);
|
|
23456
|
+
const bottomTexture = createFilledTexture(`${palette.shadow}cc`);
|
|
23457
|
+
fillTextureRect(sideTexture, 0, 0, 8, 3, hairColor);
|
|
23458
|
+
fillTextureRect(backTexture, 0, 0, 8, 5, hairColor);
|
|
23459
|
+
fillTextureRect(backTexture, 1, 5, 6, 1, hairColor);
|
|
23460
|
+
if (hasHeadband) {
|
|
23461
|
+
fillTextureRect(sideTexture, 0, 2, 8, 1, headbandColor);
|
|
23462
|
+
fillTextureRect(backTexture, 0, 2, 8, 1, headbandColor);
|
|
23463
|
+
fillTextureRect(topTexture, 0, 4, 8, 1, headbandColor);
|
|
23464
|
+
}
|
|
23465
|
+
sideTexture[4][4] = `${palette.shadow}99`;
|
|
23466
|
+
sideTexture[5][4] = `${palette.shadow}cc`;
|
|
23467
|
+
backTexture[6][2] = `${palette.shadow}99`;
|
|
23468
|
+
backTexture[6][5] = `${palette.shadow}99`;
|
|
23469
|
+
return {
|
|
23470
|
+
front: faceTexture,
|
|
23471
|
+
back: backTexture,
|
|
23472
|
+
left: sideTexture,
|
|
23473
|
+
right: mirrorMinecraftTexture(sideTexture),
|
|
23474
|
+
top: topTexture,
|
|
23475
|
+
bottom: bottomTexture,
|
|
23476
|
+
};
|
|
23477
|
+
}
|
|
23478
|
+
/**
|
|
23479
|
+
* Builds the seeded six-face texture pack used by the Minecraft-style torso cuboid.
|
|
23480
|
+
*
|
|
23481
|
+
* @param random Seeded random generator.
|
|
23482
|
+
* @param palette Derived avatar palette.
|
|
23483
|
+
* @returns Torso cuboid textures.
|
|
23484
|
+
*
|
|
23485
|
+
* @private helper of the Minecraft avatar visuals
|
|
23486
|
+
*/
|
|
23487
|
+
function createMinecraftTorsoTextures(random, palette) {
|
|
23488
|
+
const frontTexture = createMinecraftShirtTexture(random, palette);
|
|
23489
|
+
const sideTexture = createFilledTexture(palette.primary);
|
|
23490
|
+
const backTexture = createFilledTexture(palette.primary);
|
|
23491
|
+
const topTexture = createFilledTexture(`${palette.highlight}dd`);
|
|
23492
|
+
const bottomTexture = createFilledTexture(`${palette.shadow}dd`);
|
|
23493
|
+
const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
|
|
23494
|
+
fillTextureRect(sideTexture, 0, 0, 8, 2, palette.shadow);
|
|
23495
|
+
fillTextureRect(backTexture, 0, 0, 8, 2, palette.shadow);
|
|
23496
|
+
fillTextureRect(backTexture, 3, 2, 2, 6, stripeColor);
|
|
23497
|
+
fillTextureRect(sideTexture, 4, 2, 1, 6, stripeColor);
|
|
23498
|
+
fillTextureRect(topTexture, 0, 0, 8, 2, palette.shadow);
|
|
23499
|
+
fillTextureRect(topTexture, 2, 2, 4, 4, stripeColor);
|
|
23500
|
+
return {
|
|
23501
|
+
front: frontTexture,
|
|
23502
|
+
back: backTexture,
|
|
23503
|
+
left: sideTexture,
|
|
23504
|
+
right: mirrorMinecraftTexture(sideTexture),
|
|
23505
|
+
top: topTexture,
|
|
23506
|
+
bottom: bottomTexture,
|
|
23507
|
+
};
|
|
23508
|
+
}
|
|
23509
|
+
/**
|
|
23510
|
+
* Mirrors one Minecraft texture horizontally.
|
|
23511
|
+
*
|
|
23512
|
+
* @param texture Source texture.
|
|
23513
|
+
* @returns Mirrored texture copy.
|
|
23514
|
+
*
|
|
23515
|
+
* @private helper of the Minecraft avatar visuals
|
|
23516
|
+
*/
|
|
23517
|
+
function mirrorMinecraftTexture(texture) {
|
|
23518
|
+
return texture.map((row) => [...row].reverse());
|
|
23519
|
+
}
|
|
23520
|
+
/**
|
|
23521
|
+
* Creates the front-face pixel texture for the cube head.
|
|
23522
|
+
*
|
|
23523
|
+
* @param random Seeded random generator.
|
|
23524
|
+
* @param palette Derived avatar palette.
|
|
23525
|
+
* @param hasHeadband Whether the avatar should render a headband row.
|
|
23526
|
+
* @returns 8x8 pixel texture.
|
|
23527
|
+
*
|
|
23528
|
+
* @private helper of the Minecraft avatar visuals
|
|
23529
|
+
*/
|
|
23530
|
+
function createMinecraftFaceTexture(random, palette, hasHeadband) {
|
|
23531
|
+
const texture = createFilledTexture(palette.highlight);
|
|
23532
|
+
const hairlineColor = random() < 0.5 ? palette.primary : palette.secondary;
|
|
23533
|
+
const cheekColor = random() < 0.5 ? `${palette.accent}bb` : `${palette.secondary}bb`;
|
|
23534
|
+
fillTextureRect(texture, 0, 0, 8, 2, hairlineColor);
|
|
23535
|
+
texture[2][0] = hairlineColor;
|
|
23536
|
+
texture[2][7] = hairlineColor;
|
|
23537
|
+
texture[3][0] = hairlineColor;
|
|
23538
|
+
texture[3][7] = hairlineColor;
|
|
23539
|
+
if (hasHeadband) {
|
|
23540
|
+
fillTextureRect(texture, 0, 2, 8, 1, palette.accent);
|
|
23541
|
+
}
|
|
23542
|
+
texture[3][2] = palette.ink;
|
|
23543
|
+
texture[3][5] = palette.ink;
|
|
23544
|
+
texture[4][2] = '#ffffff';
|
|
23545
|
+
texture[4][5] = '#ffffff';
|
|
23546
|
+
texture[5][1] = cheekColor;
|
|
23547
|
+
texture[5][6] = cheekColor;
|
|
23548
|
+
texture[5][3] = palette.shadow;
|
|
23549
|
+
texture[5][4] = palette.shadow;
|
|
23550
|
+
texture[6][3] = palette.shadow;
|
|
23551
|
+
texture[6][4] = palette.shadow;
|
|
23552
|
+
return texture;
|
|
23553
|
+
}
|
|
23554
|
+
/**
|
|
23555
|
+
* Creates the front-face pixel texture for the torso.
|
|
23556
|
+
*
|
|
23557
|
+
* @param random Seeded random generator.
|
|
23558
|
+
* @param palette Derived avatar palette.
|
|
23559
|
+
* @returns 8x8 torso texture.
|
|
23560
|
+
*
|
|
23561
|
+
* @private helper of the Minecraft avatar visuals
|
|
23562
|
+
*/
|
|
23563
|
+
function createMinecraftShirtTexture(random, palette) {
|
|
23564
|
+
const texture = createFilledTexture(palette.primary);
|
|
23565
|
+
const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
|
|
23566
|
+
fillTextureRect(texture, 0, 0, 8, 2, palette.shadow);
|
|
23567
|
+
for (let rowIndex = 2; rowIndex < 8; rowIndex++) {
|
|
23568
|
+
texture[rowIndex][3] = stripeColor;
|
|
23569
|
+
texture[rowIndex][4] = stripeColor;
|
|
23570
|
+
}
|
|
23571
|
+
texture[4][1] = palette.accent;
|
|
23572
|
+
texture[4][6] = palette.accent;
|
|
23573
|
+
texture[5][2] = palette.highlight;
|
|
23574
|
+
texture[5][5] = palette.highlight;
|
|
23575
|
+
return texture;
|
|
23576
|
+
}
|
|
23577
|
+
/**
|
|
23578
|
+
* Creates one solid-color 8x8 Minecraft texture.
|
|
23579
|
+
*
|
|
23580
|
+
* @param color Fill color.
|
|
23581
|
+
* @returns Filled 8x8 texture.
|
|
23582
|
+
*
|
|
23583
|
+
* @private helper of the Minecraft avatar visuals
|
|
23584
|
+
*/
|
|
23585
|
+
function createFilledTexture(color) {
|
|
23586
|
+
return Array.from({ length: 8 }, () => Array.from({ length: 8 }, () => color));
|
|
23587
|
+
}
|
|
23588
|
+
/**
|
|
23589
|
+
* Fills one rectangular area inside a mutable Minecraft texture.
|
|
23590
|
+
*
|
|
23591
|
+
* @param texture Mutable target texture.
|
|
23592
|
+
* @param x Left texture coordinate.
|
|
23593
|
+
* @param y Top texture coordinate.
|
|
23594
|
+
* @param width Rectangle width.
|
|
23595
|
+
* @param height Rectangle height.
|
|
23596
|
+
* @param color Fill color.
|
|
23597
|
+
*
|
|
23598
|
+
* @private helper of the Minecraft avatar visuals
|
|
23599
|
+
*/
|
|
23600
|
+
function fillTextureRect(texture, x, y, width, height, color) {
|
|
23601
|
+
for (let rowIndex = y; rowIndex < y + height; rowIndex++) {
|
|
23602
|
+
for (let columnIndex = x; columnIndex < x + width; columnIndex++) {
|
|
23603
|
+
texture[rowIndex][columnIndex] = color;
|
|
23604
|
+
}
|
|
23605
|
+
}
|
|
23606
|
+
}
|
|
23607
|
+
|
|
23415
23608
|
/* eslint-disable no-magic-numbers */
|
|
23416
23609
|
/**
|
|
23417
23610
|
* Minecraft-style 3D avatar visual.
|
|
@@ -23436,8 +23629,8 @@
|
|
|
23436
23629
|
const bodyX = size * 0.33;
|
|
23437
23630
|
const bodyY = headY + headSize * 0.96;
|
|
23438
23631
|
const hasHeadband = random() < 0.5;
|
|
23439
|
-
const
|
|
23440
|
-
const
|
|
23632
|
+
const headTextures = createMinecraftHeadTextures(createRandom('minecraft-face'), palette, hasHeadband);
|
|
23633
|
+
const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft-shirt'), palette);
|
|
23441
23634
|
drawAvatarFrame(context, size, palette);
|
|
23442
23635
|
const spotlight = context.createRadialGradient(size * 0.5, size * 0.18, size * 0.05, size * 0.5, size * 0.18, size * 0.5);
|
|
23443
23636
|
spotlight.addColorStop(0, `${palette.highlight}66`);
|
|
@@ -23457,7 +23650,7 @@
|
|
|
23457
23650
|
width: bodyWidth,
|
|
23458
23651
|
height: bodyHeight,
|
|
23459
23652
|
depth: bodyDepth,
|
|
23460
|
-
frontTexture:
|
|
23653
|
+
frontTexture: torsoTextures.front,
|
|
23461
23654
|
topColor: `${palette.highlight}cc`,
|
|
23462
23655
|
sideColor: `${palette.secondary}dd`,
|
|
23463
23656
|
outlineColor: `${palette.shadow}aa`,
|
|
@@ -23468,7 +23661,7 @@
|
|
|
23468
23661
|
width: headSize,
|
|
23469
23662
|
height: headSize,
|
|
23470
23663
|
depth,
|
|
23471
|
-
frontTexture:
|
|
23664
|
+
frontTexture: headTextures.front,
|
|
23472
23665
|
topColor: `${palette.highlight}ee`,
|
|
23473
23666
|
sideColor: `${palette.secondary}ee`,
|
|
23474
23667
|
outlineColor: `${palette.shadow}cc`,
|
|
@@ -23533,72 +23726,505 @@
|
|
|
23533
23726
|
context.closePath();
|
|
23534
23727
|
context.stroke();
|
|
23535
23728
|
}
|
|
23729
|
+
|
|
23730
|
+
/* eslint-disable no-magic-numbers */
|
|
23536
23731
|
/**
|
|
23537
|
-
*
|
|
23732
|
+
* Fixed scene camera distance used for the proper-3D projection.
|
|
23538
23733
|
*
|
|
23539
|
-
* @
|
|
23734
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
23735
|
+
*/
|
|
23736
|
+
const CAMERA_DISTANCE_RATIO = 1.4;
|
|
23737
|
+
/**
|
|
23738
|
+
* Shared light direction used to shade projected cuboid faces.
|
|
23739
|
+
*
|
|
23740
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
23741
|
+
*/
|
|
23742
|
+
const LIGHT_DIRECTION = normalizeVector3({
|
|
23743
|
+
x: 0.4,
|
|
23744
|
+
y: -0.65,
|
|
23745
|
+
z: 0.92,
|
|
23746
|
+
});
|
|
23747
|
+
/**
|
|
23748
|
+
* Minecraft 3D 2 avatar visual.
|
|
23749
|
+
*
|
|
23750
|
+
* @private built-in avatar visual
|
|
23751
|
+
*/
|
|
23752
|
+
const minecraft2AvatarVisual = {
|
|
23753
|
+
id: 'minecraft2',
|
|
23754
|
+
title: 'Minecraft 3D 2',
|
|
23755
|
+
description: 'Proper 3D Minecraft-style portrait with textured cuboids and pointer-driven head turns.',
|
|
23756
|
+
isAnimated: true,
|
|
23757
|
+
supportsPointerTracking: true,
|
|
23758
|
+
render({ context, size, palette, createRandom, timeMs, interaction }) {
|
|
23759
|
+
const spotlightY = size * 0.22;
|
|
23760
|
+
const headRandom = createRandom('minecraft2-head');
|
|
23761
|
+
const hasHeadband = headRandom() < 0.5;
|
|
23762
|
+
const headTextures = createMinecraftHeadTextures(createRandom('minecraft2-head-textures'), palette, hasHeadband);
|
|
23763
|
+
const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft2-body-textures'), palette);
|
|
23764
|
+
const bob = Math.sin(timeMs / 880) * size * 0.014;
|
|
23765
|
+
const bodyYaw = -0.24 + Math.sin(timeMs / 2300) * 0.06 + interaction.bodyOffsetX * 0.16;
|
|
23766
|
+
const bodyPitch = -0.12 + Math.cos(timeMs / 2800) * 0.02 - interaction.bodyOffsetY * 0.06;
|
|
23767
|
+
const headYaw = -0.18 + Math.sin(timeMs / 1900 + 0.6) * 0.05 + interaction.gazeX * 0.62;
|
|
23768
|
+
const headPitch = -0.12 + Math.cos(timeMs / 2400 + 1.1) * 0.03 - interaction.gazeY * 0.38;
|
|
23769
|
+
const sceneCenterX = size * 0.5;
|
|
23770
|
+
const sceneCenterY = size * 0.57;
|
|
23771
|
+
const bodyWidth = size * 0.225;
|
|
23772
|
+
const bodyHeight = size * 0.245;
|
|
23773
|
+
const bodyDepth = size * 0.145;
|
|
23774
|
+
const headSize = size * 0.24;
|
|
23775
|
+
const headLift = size * 0.205;
|
|
23776
|
+
const headForwardShift = interaction.intensity * size * 0.018;
|
|
23777
|
+
const sceneCuboids = [
|
|
23778
|
+
{
|
|
23779
|
+
center: {
|
|
23780
|
+
x: interaction.bodyOffsetX * size * 0.026,
|
|
23781
|
+
y: size * 0.05 + interaction.bodyOffsetY * size * 0.018 + bob,
|
|
23782
|
+
z: 0,
|
|
23783
|
+
},
|
|
23784
|
+
width: bodyWidth,
|
|
23785
|
+
height: bodyHeight,
|
|
23786
|
+
depth: bodyDepth,
|
|
23787
|
+
rotationX: bodyPitch,
|
|
23788
|
+
rotationY: bodyYaw,
|
|
23789
|
+
textures: torsoTextures,
|
|
23790
|
+
outlineColor: `${palette.shadow}cc`,
|
|
23791
|
+
},
|
|
23792
|
+
{
|
|
23793
|
+
center: {
|
|
23794
|
+
x: interaction.bodyOffsetX * size * 0.018 + interaction.gazeX * size * 0.016,
|
|
23795
|
+
y: -headLift + bob * 1.15,
|
|
23796
|
+
z: headForwardShift,
|
|
23797
|
+
},
|
|
23798
|
+
width: headSize,
|
|
23799
|
+
height: headSize,
|
|
23800
|
+
depth: headSize,
|
|
23801
|
+
rotationX: headPitch,
|
|
23802
|
+
rotationY: headYaw,
|
|
23803
|
+
textures: headTextures,
|
|
23804
|
+
outlineColor: `${palette.shadow}dd`,
|
|
23805
|
+
},
|
|
23806
|
+
];
|
|
23807
|
+
const visibleFaces = sceneCuboids
|
|
23808
|
+
.flatMap((cuboid) => resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY))
|
|
23809
|
+
.sort((firstFace, secondFace) => firstFace.averageDepth - secondFace.averageDepth);
|
|
23810
|
+
drawAvatarFrame(context, size, palette);
|
|
23811
|
+
drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs);
|
|
23812
|
+
drawMinecraftShadow(context, size, palette, interaction, timeMs);
|
|
23813
|
+
for (const visibleFace of visibleFaces) {
|
|
23814
|
+
drawTexturedProjectedFace(context, visibleFace);
|
|
23815
|
+
}
|
|
23816
|
+
},
|
|
23817
|
+
};
|
|
23818
|
+
/**
|
|
23819
|
+
* Draws the shared background atmosphere behind the Minecraft 3D 2 portrait.
|
|
23820
|
+
*
|
|
23821
|
+
* @param context Canvas 2D context.
|
|
23822
|
+
* @param size Canvas size in CSS pixels.
|
|
23540
23823
|
* @param palette Derived avatar palette.
|
|
23541
|
-
* @param
|
|
23542
|
-
* @
|
|
23824
|
+
* @param sceneCenterX Horizontal scene center.
|
|
23825
|
+
* @param spotlightY Vertical spotlight anchor.
|
|
23826
|
+
* @param interaction Smoothed pointer-aware interaction state.
|
|
23827
|
+
* @param timeMs Current animation time in milliseconds.
|
|
23543
23828
|
*
|
|
23544
|
-
* @private helper of `
|
|
23829
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
23545
23830
|
*/
|
|
23546
|
-
function
|
|
23547
|
-
const
|
|
23548
|
-
|
|
23549
|
-
|
|
23550
|
-
|
|
23551
|
-
|
|
23552
|
-
|
|
23831
|
+
function drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs) {
|
|
23832
|
+
const spotlightGradient = context.createRadialGradient(sceneCenterX + interaction.gazeX * size * 0.08, spotlightY + interaction.gazeY * size * 0.05, size * 0.03, sceneCenterX, spotlightY, size * 0.52);
|
|
23833
|
+
spotlightGradient.addColorStop(0, `${palette.highlight}66`);
|
|
23834
|
+
spotlightGradient.addColorStop(0.42, `${palette.accent}1d`);
|
|
23835
|
+
spotlightGradient.addColorStop(1, `${palette.highlight}00`);
|
|
23836
|
+
context.fillStyle = spotlightGradient;
|
|
23837
|
+
context.fillRect(0, 0, size, size);
|
|
23838
|
+
const rimGradient = context.createLinearGradient(0, size * 0.14, 0, size * 0.92);
|
|
23839
|
+
rimGradient.addColorStop(0, `${palette.highlight}12`);
|
|
23840
|
+
rimGradient.addColorStop(0.55, `${palette.secondary}0a`);
|
|
23841
|
+
rimGradient.addColorStop(1, `${palette.shadow}00`);
|
|
23842
|
+
context.fillStyle = rimGradient;
|
|
23843
|
+
context.fillRect(0, 0, size, size);
|
|
23844
|
+
context.save();
|
|
23845
|
+
context.globalAlpha = 0.08 + interaction.intensity * 0.04;
|
|
23846
|
+
context.fillStyle = palette.highlight;
|
|
23847
|
+
context.beginPath();
|
|
23848
|
+
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);
|
|
23849
|
+
context.fill();
|
|
23850
|
+
context.restore();
|
|
23851
|
+
}
|
|
23852
|
+
/**
|
|
23853
|
+
* Draws the soft floor shadow used to anchor the cuboids in the frame.
|
|
23854
|
+
*
|
|
23855
|
+
* @param context Canvas 2D context.
|
|
23856
|
+
* @param size Canvas size in CSS pixels.
|
|
23857
|
+
* @param palette Derived avatar palette.
|
|
23858
|
+
* @param interaction Smoothed pointer-aware interaction state.
|
|
23859
|
+
* @param timeMs Current animation time in milliseconds.
|
|
23860
|
+
*
|
|
23861
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
23862
|
+
*/
|
|
23863
|
+
function drawMinecraftShadow(context, size, palette, interaction, timeMs) {
|
|
23864
|
+
context.save();
|
|
23865
|
+
context.fillStyle = `${palette.shadow}66`;
|
|
23866
|
+
context.filter = `blur(${size * 0.02}px)`;
|
|
23867
|
+
context.beginPath();
|
|
23868
|
+
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);
|
|
23869
|
+
context.fill();
|
|
23870
|
+
context.restore();
|
|
23871
|
+
}
|
|
23872
|
+
/**
|
|
23873
|
+
* Resolves all visible projected faces for one scene cuboid.
|
|
23874
|
+
*
|
|
23875
|
+
* @param cuboid Scene cuboid definition.
|
|
23876
|
+
* @param size Canvas size in CSS pixels.
|
|
23877
|
+
* @param sceneCenterX Horizontal scene center.
|
|
23878
|
+
* @param sceneCenterY Vertical scene center.
|
|
23879
|
+
* @returns Visible faces sorted later by depth.
|
|
23880
|
+
*
|
|
23881
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
23882
|
+
*/
|
|
23883
|
+
function resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY) {
|
|
23884
|
+
const halfWidth = cuboid.width / 2;
|
|
23885
|
+
const halfHeight = cuboid.height / 2;
|
|
23886
|
+
const halfDepth = cuboid.depth / 2;
|
|
23887
|
+
const faceDefinitions = [
|
|
23888
|
+
{
|
|
23889
|
+
texture: cuboid.textures.front,
|
|
23890
|
+
corners: [
|
|
23891
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
23892
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
23893
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
23894
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
23895
|
+
],
|
|
23896
|
+
},
|
|
23897
|
+
{
|
|
23898
|
+
texture: cuboid.textures.back,
|
|
23899
|
+
corners: [
|
|
23900
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
23901
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
23902
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
23903
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
23904
|
+
],
|
|
23905
|
+
},
|
|
23906
|
+
{
|
|
23907
|
+
texture: cuboid.textures.right,
|
|
23908
|
+
corners: [
|
|
23909
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
23910
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
23911
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
23912
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
23913
|
+
],
|
|
23914
|
+
},
|
|
23915
|
+
{
|
|
23916
|
+
texture: cuboid.textures.left,
|
|
23917
|
+
corners: [
|
|
23918
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
23919
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
23920
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
23921
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
23922
|
+
],
|
|
23923
|
+
},
|
|
23924
|
+
{
|
|
23925
|
+
texture: cuboid.textures.top,
|
|
23926
|
+
corners: [
|
|
23927
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
23928
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
23929
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
23930
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
23931
|
+
],
|
|
23932
|
+
},
|
|
23933
|
+
{
|
|
23934
|
+
texture: cuboid.textures.bottom,
|
|
23935
|
+
corners: [
|
|
23936
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
23937
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
23938
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
23939
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
23940
|
+
],
|
|
23941
|
+
},
|
|
23942
|
+
];
|
|
23943
|
+
const visibleFaces = faceDefinitions
|
|
23944
|
+
.map((faceDefinition) => {
|
|
23945
|
+
const transformedCorners = faceDefinition.corners.map((corner) => transformScenePoint(corner, cuboid.center, cuboid.rotationX, cuboid.rotationY));
|
|
23946
|
+
const faceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
|
|
23947
|
+
if (faceNormal.z <= 0.02) {
|
|
23948
|
+
return null;
|
|
23553
23949
|
}
|
|
23950
|
+
const projectedCorners = transformedCorners.map((corner) => projectScenePoint(corner, size, sceneCenterX, sceneCenterY));
|
|
23951
|
+
return {
|
|
23952
|
+
corners: projectedCorners,
|
|
23953
|
+
texture: faceDefinition.texture,
|
|
23954
|
+
averageDepth: transformedCorners.reduce((depthSum, corner) => depthSum + corner.z, 0) / transformedCorners.length,
|
|
23955
|
+
lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION), -1, 1),
|
|
23956
|
+
outlineColor: cuboid.outlineColor,
|
|
23957
|
+
};
|
|
23958
|
+
});
|
|
23959
|
+
return visibleFaces.filter((visibleFace) => visibleFace !== null);
|
|
23960
|
+
}
|
|
23961
|
+
/**
|
|
23962
|
+
* Draws one projected textured face by tessellating its texture cells into quads.
|
|
23963
|
+
*
|
|
23964
|
+
* @param context Canvas 2D context.
|
|
23965
|
+
* @param face Visible projected face.
|
|
23966
|
+
*
|
|
23967
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
23968
|
+
*/
|
|
23969
|
+
function drawTexturedProjectedFace(context, face) {
|
|
23970
|
+
var _a;
|
|
23971
|
+
const rows = face.texture.length;
|
|
23972
|
+
const columns = ((_a = face.texture[0]) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
23973
|
+
if (rows === 0 || columns === 0) {
|
|
23974
|
+
return;
|
|
23554
23975
|
}
|
|
23555
|
-
|
|
23556
|
-
|
|
23557
|
-
|
|
23558
|
-
|
|
23559
|
-
|
|
23560
|
-
|
|
23561
|
-
|
|
23976
|
+
for (let rowIndex = 0; rowIndex < rows; rowIndex++) {
|
|
23977
|
+
for (let columnIndex = 0; columnIndex < columns; columnIndex++) {
|
|
23978
|
+
const startX = columnIndex / columns;
|
|
23979
|
+
const endX = (columnIndex + 1) / columns;
|
|
23980
|
+
const startY = rowIndex / rows;
|
|
23981
|
+
const endY = (rowIndex + 1) / rows;
|
|
23982
|
+
drawProjectedQuad(context, [
|
|
23983
|
+
interpolateProjectedQuad(face.corners, startX, startY),
|
|
23984
|
+
interpolateProjectedQuad(face.corners, endX, startY),
|
|
23985
|
+
interpolateProjectedQuad(face.corners, endX, endY),
|
|
23986
|
+
interpolateProjectedQuad(face.corners, startX, endY),
|
|
23987
|
+
], face.texture[rowIndex][columnIndex]);
|
|
23562
23988
|
}
|
|
23563
23989
|
}
|
|
23564
|
-
|
|
23565
|
-
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23571
|
-
|
|
23572
|
-
|
|
23573
|
-
|
|
23574
|
-
|
|
23990
|
+
if (face.lightIntensity > 0) {
|
|
23991
|
+
drawProjectedQuad(context, face.corners, `rgba(255, 255, 255, ${0.15 * face.lightIntensity})`);
|
|
23992
|
+
}
|
|
23993
|
+
else if (face.lightIntensity < 0) {
|
|
23994
|
+
drawProjectedQuad(context, face.corners, `rgba(0, 0, 0, ${0.22 * Math.abs(face.lightIntensity)})`);
|
|
23995
|
+
}
|
|
23996
|
+
context.save();
|
|
23997
|
+
context.beginPath();
|
|
23998
|
+
context.moveTo(face.corners[0].x, face.corners[0].y);
|
|
23999
|
+
for (let cornerIndex = 1; cornerIndex < face.corners.length; cornerIndex++) {
|
|
24000
|
+
context.lineTo(face.corners[cornerIndex].x, face.corners[cornerIndex].y);
|
|
24001
|
+
}
|
|
24002
|
+
context.closePath();
|
|
24003
|
+
context.strokeStyle = face.outlineColor;
|
|
24004
|
+
context.lineWidth = Math.max(1.1, getProjectedQuadPerimeter(face.corners) * 0.0045);
|
|
24005
|
+
context.lineJoin = 'round';
|
|
24006
|
+
context.stroke();
|
|
24007
|
+
context.restore();
|
|
23575
24008
|
}
|
|
23576
24009
|
/**
|
|
23577
|
-
*
|
|
24010
|
+
* Draws one filled projected quad.
|
|
23578
24011
|
*
|
|
23579
|
-
* @param
|
|
23580
|
-
* @param
|
|
23581
|
-
* @
|
|
24012
|
+
* @param context Canvas 2D context.
|
|
24013
|
+
* @param corners Quad corners in clockwise order.
|
|
24014
|
+
* @param fillStyle CSS fill style.
|
|
23582
24015
|
*
|
|
23583
|
-
* @private helper of `
|
|
24016
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
23584
24017
|
*/
|
|
23585
|
-
function
|
|
23586
|
-
|
|
23587
|
-
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23591
|
-
|
|
24018
|
+
function drawProjectedQuad(context, corners, fillStyle) {
|
|
24019
|
+
context.beginPath();
|
|
24020
|
+
context.moveTo(corners[0].x, corners[0].y);
|
|
24021
|
+
context.lineTo(corners[1].x, corners[1].y);
|
|
24022
|
+
context.lineTo(corners[2].x, corners[2].y);
|
|
24023
|
+
context.lineTo(corners[3].x, corners[3].y);
|
|
24024
|
+
context.closePath();
|
|
24025
|
+
context.fillStyle = fillStyle;
|
|
24026
|
+
context.fill();
|
|
24027
|
+
}
|
|
24028
|
+
/**
|
|
24029
|
+
* Interpolates one point inside a projected quad across both quad axes.
|
|
24030
|
+
*
|
|
24031
|
+
* @param corners Quad corners in clockwise order.
|
|
24032
|
+
* @param horizontalRatio Horizontal ratio in the range `[0, 1]`.
|
|
24033
|
+
* @param verticalRatio Vertical ratio in the range `[0, 1]`.
|
|
24034
|
+
* @returns Interpolated projected point.
|
|
24035
|
+
*
|
|
24036
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24037
|
+
*/
|
|
24038
|
+
function interpolateProjectedQuad(corners, horizontalRatio, verticalRatio) {
|
|
24039
|
+
const topPoint = interpolateProjectedPoint(corners[0], corners[1], horizontalRatio);
|
|
24040
|
+
const bottomPoint = interpolateProjectedPoint(corners[3], corners[2], horizontalRatio);
|
|
24041
|
+
return interpolateProjectedPoint(topPoint, bottomPoint, verticalRatio);
|
|
24042
|
+
}
|
|
24043
|
+
/**
|
|
24044
|
+
* Interpolates between two projected points.
|
|
24045
|
+
*
|
|
24046
|
+
* @param startPoint Start point.
|
|
24047
|
+
* @param endPoint End point.
|
|
24048
|
+
* @param ratio Interpolation ratio in the range `[0, 1]`.
|
|
24049
|
+
* @returns Interpolated projected point.
|
|
24050
|
+
*
|
|
24051
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24052
|
+
*/
|
|
24053
|
+
function interpolateProjectedPoint(startPoint, endPoint, ratio) {
|
|
24054
|
+
return {
|
|
24055
|
+
x: startPoint.x + (endPoint.x - startPoint.x) * ratio,
|
|
24056
|
+
y: startPoint.y + (endPoint.y - startPoint.y) * ratio,
|
|
24057
|
+
z: startPoint.z + (endPoint.z - startPoint.z) * ratio,
|
|
24058
|
+
};
|
|
24059
|
+
}
|
|
24060
|
+
/**
|
|
24061
|
+
* Projects one rotated scene point into canvas coordinates.
|
|
24062
|
+
*
|
|
24063
|
+
* @param point Scene point.
|
|
24064
|
+
* @param size Canvas size in CSS pixels.
|
|
24065
|
+
* @param sceneCenterX Horizontal scene center.
|
|
24066
|
+
* @param sceneCenterY Vertical scene center.
|
|
24067
|
+
* @returns Projected point.
|
|
24068
|
+
*
|
|
24069
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24070
|
+
*/
|
|
24071
|
+
function projectScenePoint(point, size, sceneCenterX, sceneCenterY) {
|
|
24072
|
+
const cameraDistance = size * CAMERA_DISTANCE_RATIO;
|
|
24073
|
+
const perspectiveScale = cameraDistance / Math.max(cameraDistance - point.z, cameraDistance * 0.35);
|
|
24074
|
+
return {
|
|
24075
|
+
x: sceneCenterX + point.x * perspectiveScale,
|
|
24076
|
+
y: sceneCenterY + point.y * perspectiveScale,
|
|
24077
|
+
z: point.z,
|
|
24078
|
+
};
|
|
24079
|
+
}
|
|
24080
|
+
/**
|
|
24081
|
+
* Applies the local cuboid rotations and translation to one scene point.
|
|
24082
|
+
*
|
|
24083
|
+
* @param localPoint Point in cuboid-local space.
|
|
24084
|
+
* @param center Cuboid center in scene space.
|
|
24085
|
+
* @param rotationX Cuboid pitch in radians.
|
|
24086
|
+
* @param rotationY Cuboid yaw in radians.
|
|
24087
|
+
* @returns Transformed scene-space point.
|
|
24088
|
+
*
|
|
24089
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24090
|
+
*/
|
|
24091
|
+
function transformScenePoint(localPoint, center, rotationX, rotationY) {
|
|
24092
|
+
const yawedPoint = rotatePointAroundY(localPoint, rotationY);
|
|
24093
|
+
const pitchedPoint = rotatePointAroundX(yawedPoint, rotationX);
|
|
24094
|
+
return {
|
|
24095
|
+
x: center.x + pitchedPoint.x,
|
|
24096
|
+
y: center.y + pitchedPoint.y,
|
|
24097
|
+
z: center.z + pitchedPoint.z,
|
|
24098
|
+
};
|
|
24099
|
+
}
|
|
24100
|
+
/**
|
|
24101
|
+
* Rotates one point around the local Y axis.
|
|
24102
|
+
*
|
|
24103
|
+
* @param point Source point.
|
|
24104
|
+
* @param angle Rotation angle in radians.
|
|
24105
|
+
* @returns Rotated point.
|
|
24106
|
+
*
|
|
24107
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24108
|
+
*/
|
|
24109
|
+
function rotatePointAroundY(point, angle) {
|
|
24110
|
+
const cosine = Math.cos(angle);
|
|
24111
|
+
const sine = Math.sin(angle);
|
|
24112
|
+
return {
|
|
24113
|
+
x: point.x * cosine + point.z * sine,
|
|
24114
|
+
y: point.y,
|
|
24115
|
+
z: -point.x * sine + point.z * cosine,
|
|
24116
|
+
};
|
|
24117
|
+
}
|
|
24118
|
+
/**
|
|
24119
|
+
* Rotates one point around the local X axis.
|
|
24120
|
+
*
|
|
24121
|
+
* @param point Source point.
|
|
24122
|
+
* @param angle Rotation angle in radians.
|
|
24123
|
+
* @returns Rotated point.
|
|
24124
|
+
*
|
|
24125
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24126
|
+
*/
|
|
24127
|
+
function rotatePointAroundX(point, angle) {
|
|
24128
|
+
const cosine = Math.cos(angle);
|
|
24129
|
+
const sine = Math.sin(angle);
|
|
24130
|
+
return {
|
|
24131
|
+
x: point.x,
|
|
24132
|
+
y: point.y * cosine - point.z * sine,
|
|
24133
|
+
z: point.y * sine + point.z * cosine,
|
|
24134
|
+
};
|
|
24135
|
+
}
|
|
24136
|
+
/**
|
|
24137
|
+
* Subtracts one 3D point from another.
|
|
24138
|
+
*
|
|
24139
|
+
* @param leftPoint Left point.
|
|
24140
|
+
* @param rightPoint Right point.
|
|
24141
|
+
* @returns Difference vector.
|
|
24142
|
+
*
|
|
24143
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24144
|
+
*/
|
|
24145
|
+
function subtractPoint3D(leftPoint, rightPoint) {
|
|
24146
|
+
return {
|
|
24147
|
+
x: leftPoint.x - rightPoint.x,
|
|
24148
|
+
y: leftPoint.y - rightPoint.y,
|
|
24149
|
+
z: leftPoint.z - rightPoint.z,
|
|
24150
|
+
};
|
|
24151
|
+
}
|
|
24152
|
+
/**
|
|
24153
|
+
* Computes the 3D cross product of two vectors.
|
|
24154
|
+
*
|
|
24155
|
+
* @param leftVector Left vector.
|
|
24156
|
+
* @param rightVector Right vector.
|
|
24157
|
+
* @returns Cross product.
|
|
24158
|
+
*
|
|
24159
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24160
|
+
*/
|
|
24161
|
+
function crossProduct3D(leftVector, rightVector) {
|
|
24162
|
+
return {
|
|
24163
|
+
x: leftVector.y * rightVector.z - leftVector.z * rightVector.y,
|
|
24164
|
+
y: leftVector.z * rightVector.x - leftVector.x * rightVector.z,
|
|
24165
|
+
z: leftVector.x * rightVector.y - leftVector.y * rightVector.x,
|
|
24166
|
+
};
|
|
24167
|
+
}
|
|
24168
|
+
/**
|
|
24169
|
+
* Computes the 3D dot product of two vectors.
|
|
24170
|
+
*
|
|
24171
|
+
* @param leftVector Left vector.
|
|
24172
|
+
* @param rightVector Right vector.
|
|
24173
|
+
* @returns Dot product.
|
|
24174
|
+
*
|
|
24175
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24176
|
+
*/
|
|
24177
|
+
function dotProduct3D(leftVector, rightVector) {
|
|
24178
|
+
return leftVector.x * rightVector.x + leftVector.y * rightVector.y + leftVector.z * rightVector.z;
|
|
24179
|
+
}
|
|
24180
|
+
/**
|
|
24181
|
+
* Normalizes one 3D vector while keeping zero vectors stable.
|
|
24182
|
+
*
|
|
24183
|
+
* @param vector Source vector.
|
|
24184
|
+
* @returns Normalized vector.
|
|
24185
|
+
*
|
|
24186
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24187
|
+
*/
|
|
24188
|
+
function normalizeVector3(vector) {
|
|
24189
|
+
const length = Math.hypot(vector.x, vector.y, vector.z);
|
|
24190
|
+
if (length === 0) {
|
|
24191
|
+
return vector;
|
|
23592
24192
|
}
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
24193
|
+
return {
|
|
24194
|
+
x: vector.x / length,
|
|
24195
|
+
y: vector.y / length,
|
|
24196
|
+
z: vector.z / length,
|
|
24197
|
+
};
|
|
24198
|
+
}
|
|
24199
|
+
/**
|
|
24200
|
+
* Clamps one number into the provided range.
|
|
24201
|
+
*
|
|
24202
|
+
* @param value Input value.
|
|
24203
|
+
* @param minimumValue Inclusive lower bound.
|
|
24204
|
+
* @param maximumValue Inclusive upper bound.
|
|
24205
|
+
* @returns Clamped value.
|
|
24206
|
+
*
|
|
24207
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24208
|
+
*/
|
|
24209
|
+
function clampNumber$1(value, minimumValue, maximumValue) {
|
|
24210
|
+
return Math.min(maximumValue, Math.max(minimumValue, value));
|
|
24211
|
+
}
|
|
24212
|
+
/**
|
|
24213
|
+
* Measures the perimeter of one projected quad.
|
|
24214
|
+
*
|
|
24215
|
+
* @param corners Quad corners.
|
|
24216
|
+
* @returns Perimeter length.
|
|
24217
|
+
*
|
|
24218
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
24219
|
+
*/
|
|
24220
|
+
function getProjectedQuadPerimeter(corners) {
|
|
24221
|
+
let perimeter = 0;
|
|
24222
|
+
for (let cornerIndex = 0; cornerIndex < corners.length; cornerIndex++) {
|
|
24223
|
+
const currentCorner = corners[cornerIndex];
|
|
24224
|
+
const nextCorner = corners[(cornerIndex + 1) % corners.length];
|
|
24225
|
+
perimeter += Math.hypot(nextCorner.x - currentCorner.x, nextCorner.y - currentCorner.y);
|
|
23596
24226
|
}
|
|
23597
|
-
|
|
23598
|
-
texture[4][6] = palette.accent;
|
|
23599
|
-
texture[5][2] = palette.highlight;
|
|
23600
|
-
texture[5][5] = palette.highlight;
|
|
23601
|
-
return texture;
|
|
24227
|
+
return perimeter;
|
|
23602
24228
|
}
|
|
23603
24229
|
|
|
23604
24230
|
/* eslint-disable no-magic-numbers */
|
|
@@ -25203,6 +25829,7 @@
|
|
|
25203
25829
|
octopus3AvatarVisual,
|
|
25204
25830
|
asciiOctopusAvatarVisual,
|
|
25205
25831
|
minecraftAvatarVisual,
|
|
25832
|
+
minecraft2AvatarVisual,
|
|
25206
25833
|
fractalAvatarVisual,
|
|
25207
25834
|
orbAvatarVisual,
|
|
25208
25835
|
];
|
|
@@ -27411,7 +28038,10 @@
|
|
|
27411
28038
|
*/
|
|
27412
28039
|
function buildTeamToolDescription(entry) {
|
|
27413
28040
|
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
27414
|
-
return
|
|
28041
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
28042
|
+
Consult teammate ${entry.teammate.label}
|
|
28043
|
+
${block(detailLines.join('\n'))}
|
|
28044
|
+
`);
|
|
27415
28045
|
}
|
|
27416
28046
|
/**
|
|
27417
28047
|
* Collects structured teammate details that should stay visible to the model.
|
|
@@ -32698,7 +33328,10 @@
|
|
|
32698
33328
|
if (hiddenCount > 0) {
|
|
32699
33329
|
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
32700
33330
|
}
|
|
32701
|
-
return
|
|
33331
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
33332
|
+
Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:
|
|
33333
|
+
${block(summaryRows.join('\n'))}
|
|
33334
|
+
`);
|
|
32702
33335
|
}
|
|
32703
33336
|
/**
|
|
32704
33337
|
* Formats one timeout row for assistant-visible timeout listings.
|