@promptbook/browser 0.112.0-102 → 0.112.0-104

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.
@@ -7,7 +7,7 @@ import type { AvatarDefinition } from './AvatarDefinition';
7
7
  *
8
8
  * @private shared contract for the avatar rendering system
9
9
  */
10
- export type AvatarVisualId = 'pixel-art' | 'octopus' | 'octopus2' | 'octopus3' | 'octopus3d' | 'octopus3d2' | 'ascii-octopus' | 'minecraft' | 'minecraft2' | 'fractal' | 'orb';
10
+ export type AvatarVisualId = 'pixel-art' | 'octopus' | 'octopus2' | 'octopus3' | 'octopus3d' | 'octopus3d2' | 'octopus3d3' | 'ascii-octopus' | 'minecraft' | 'minecraft2' | 'fractal' | 'orb';
11
11
  /**
12
12
  * Derived color palette used by avatar visuals.
13
13
  *
@@ -0,0 +1,7 @@
1
+ import type { AvatarVisualDefinition } from '../types/AvatarVisualDefinition';
2
+ /**
3
+ * Octopus 3D 3 avatar visual.
4
+ *
5
+ * @private built-in avatar visual
6
+ */
7
+ export declare const octopus3d3AvatarVisual: AvatarVisualDefinition;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.112.0-101`).
18
+ * It follows semantic versioning (e.g., `0.112.0-102`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/browser",
3
- "version": "0.112.0-102",
3
+ "version": "0.112.0-104",
4
4
  "description": "Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -98,7 +98,7 @@
98
98
  "types": "./esm/src/_packages/browser.index.d.ts",
99
99
  "typings": "./esm/src/_packages/browser.index.d.ts",
100
100
  "peerDependencies": {
101
- "@promptbook/core": "0.112.0-102"
101
+ "@promptbook/core": "0.112.0-104"
102
102
  },
103
103
  "dependencies": {
104
104
  "@openai/agents": "0.4.15",
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-102';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-104';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6635,7 +6635,7 @@
6635
6635
  *
6636
6636
  * @private helper of `minecraft2AvatarVisual`
6637
6637
  */
6638
- const LIGHT_DIRECTION$2 = normalizeVector3({
6638
+ const LIGHT_DIRECTION$3 = normalizeVector3({
6639
6639
  x: 0.4,
6640
6640
  y: -0.65,
6641
6641
  z: 0.92,
@@ -6847,7 +6847,7 @@
6847
6847
  corners: projectedCorners,
6848
6848
  texture: faceDefinition.texture,
6849
6849
  averageDepth: transformedCorners.reduce((depthSum, corner) => depthSum + corner.z, 0) / transformedCorners.length,
6850
- lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION$2), -1, 1),
6850
+ lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION$3), -1, 1),
6851
6851
  outlineColor: cuboid.outlineColor,
6852
6852
  };
6853
6853
  });
@@ -8038,7 +8038,7 @@
8038
8038
  *
8039
8039
  * @private helper of `octopus3dAvatarVisual`
8040
8040
  */
8041
- const LIGHT_DIRECTION$1 = normalizeVector3({
8041
+ const LIGHT_DIRECTION$2 = normalizeVector3({
8042
8042
  x: 0.48,
8043
8043
  y: -0.62,
8044
8044
  z: 0.94,
@@ -8248,7 +8248,7 @@
8248
8248
  corners: projectedCorners,
8249
8249
  averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
8250
8250
  transformedCorners.length,
8251
- lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
8251
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$2), -1, 1),
8252
8252
  fillStyle: resolveSurfacePatchFillStyle(palette, verticalProgress + verticalColorBias),
8253
8253
  outlineColor,
8254
8254
  });
@@ -8437,7 +8437,7 @@
8437
8437
  *
8438
8438
  * @private helper of `octopus3d2AvatarVisual`
8439
8439
  */
8440
- const LIGHT_DIRECTION = normalizeVector3({
8440
+ const LIGHT_DIRECTION$1 = normalizeVector3({
8441
8441
  x: 0.38,
8442
8442
  y: -0.6,
8443
8443
  z: 0.98,
@@ -8586,7 +8586,7 @@
8586
8586
  corners: projectedCorners,
8587
8587
  averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
8588
8588
  transformedCorners.length,
8589
- lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
8589
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
8590
8590
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
8591
8591
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
8592
8592
  });
@@ -8686,6 +8686,516 @@
8686
8686
  context.restore();
8687
8687
  }
8688
8688
 
8689
+ /* eslint-disable no-magic-numbers */
8690
+ /**
8691
+ * Light direction used by the continuous octopus mesh shading.
8692
+ *
8693
+ * @private helper of `octopus3d3AvatarVisual`
8694
+ */
8695
+ const LIGHT_DIRECTION = normalizeVector3({
8696
+ x: 0.34,
8697
+ y: -0.62,
8698
+ z: 1,
8699
+ });
8700
+ /**
8701
+ * Real-octopus tentacle count used by the continuous lower mesh.
8702
+ *
8703
+ * @private helper of `octopus3d3AvatarVisual`
8704
+ */
8705
+ const OCTOPUS_TENTACLE_COUNT = 8;
8706
+ /**
8707
+ * Octopus 3D 3 avatar visual.
8708
+ *
8709
+ * @private built-in avatar visual
8710
+ */
8711
+ const octopus3d3AvatarVisual = {
8712
+ id: 'octopus3d3',
8713
+ title: 'Octopus 3D 3',
8714
+ description: 'Cute continuous 3D octopus with a blobby single mesh, waving tentacle lobes, rich shading, and cursor-aware eyes.',
8715
+ isAnimated: true,
8716
+ supportsPointerTracking: true,
8717
+ render({ context, size, palette, createRandom, timeMs, interaction }) {
8718
+ const morphologyProfile = createOctopus3MorphologyProfile(createRandom);
8719
+ const animationRandom = createRandom('octopus3d3-animation-profile');
8720
+ const eyeRandom = createRandom('octopus3d3-eye-profile');
8721
+ const animationPhase = animationRandom() * Math.PI * 2;
8722
+ const tentacleProfiles = createContinuousTentacleProfiles(createRandom, morphologyProfile);
8723
+ const sceneCenterX = size * 0.5;
8724
+ const sceneCenterY = size * 0.535;
8725
+ const bob = Math.sin(timeMs / 960 + animationPhase) * size * 0.012;
8726
+ const meshCenter = {
8727
+ x: interaction.bodyOffsetX * size * 0.048 + size * morphologyProfile.body.centerXJitterRatio * 0.44,
8728
+ y: -size * 0.07 + interaction.bodyOffsetY * size * 0.026 + bob,
8729
+ z: interaction.intensity * size * 0.018,
8730
+ };
8731
+ const rotationY = -0.1 +
8732
+ Math.sin(timeMs / 2700 + animationPhase) * 0.035 +
8733
+ interaction.bodyOffsetX * 0.22 +
8734
+ interaction.gazeX * 0.88;
8735
+ const rotationX = -0.07 +
8736
+ Math.cos(timeMs / 3100 + animationPhase * 0.7) * 0.018 -
8737
+ interaction.bodyOffsetY * 0.08 -
8738
+ interaction.gazeY * 0.38;
8739
+ const surfaceOptions = {
8740
+ radiusX: size * morphologyProfile.body.bodyRadiusRatio * morphologyProfile.body.horizontalStretch * 1.1,
8741
+ radiusY: size * morphologyProfile.body.bodyRadiusRatio * morphologyProfile.body.verticalStretch * 1.08,
8742
+ radiusZ: size *
8743
+ morphologyProfile.body.bodyRadiusRatio *
8744
+ (1.02 + (morphologyProfile.body.horizontalStretch - 1) * 0.18),
8745
+ morphologyProfile,
8746
+ timeMs,
8747
+ animationPhase,
8748
+ tentacleProfiles,
8749
+ };
8750
+ const surfacePatches = resolveVisibleContinuousOctopusPatches({
8751
+ ...surfaceOptions,
8752
+ center: meshCenter,
8753
+ rotationX,
8754
+ rotationY,
8755
+ sceneCenterX,
8756
+ sceneCenterY,
8757
+ size,
8758
+ palette,
8759
+ });
8760
+ const eyeLatitude = clampNumber$1(morphologyProfile.face.eyeCenterYOffsetRatio * 4.2 - 0.03, -0.22, 0.08);
8761
+ const eyeLongitude = clampNumber$1(morphologyProfile.face.eyeSpacingRatio * 3.1, 0.18, 0.32);
8762
+ const mouthLatitude = clampNumber$1(eyeLatitude + 0.2 + morphologyProfile.face.mouthYOffsetRatio, 0.08, 0.34);
8763
+ const mouthCenterLongitude = clampNumber$1(morphologyProfile.face.mouthCenterOffsetRatio * 5.6, -0.08, 0.08);
8764
+ const mouthHalfLongitude = clampNumber$1(eyeLongitude * 0.78, 0.15, 0.28);
8765
+ const mouthCurveLatitude = clampNumber$1(mouthLatitude + morphologyProfile.face.mouthCurveDepthRatio * 0.78, mouthLatitude + 0.03, 0.42);
8766
+ const eyeRadiusX = size * morphologyProfile.face.eyeRadiusXRatio * 0.76;
8767
+ const eyeRadiusY = eyeRadiusX * morphologyProfile.face.eyeHeightRatio * 0.9;
8768
+ drawAvatarFrame(context, size, palette);
8769
+ drawContinuousOctopusAtmosphere(context, size, palette, sceneCenterX, sceneCenterY, interaction, timeMs);
8770
+ drawContinuousOctopusShadow(context, size, palette, interaction, timeMs, morphologyProfile);
8771
+ for (const surfacePatch of surfacePatches.sort((firstSurfacePatch, secondSurfacePatch) => firstSurfacePatch.averageDepth - secondSurfacePatch.averageDepth)) {
8772
+ drawContinuousSurfacePatch(context, surfacePatch);
8773
+ }
8774
+ drawProjectedSurfaceCurrents({
8775
+ context,
8776
+ surfaceOptions,
8777
+ center: meshCenter,
8778
+ rotationX,
8779
+ rotationY,
8780
+ sceneCenterX,
8781
+ sceneCenterY,
8782
+ size,
8783
+ palette,
8784
+ morphologyProfile,
8785
+ timeMs,
8786
+ animationPhase,
8787
+ });
8788
+ drawProjectedTentacleSuckers({
8789
+ context,
8790
+ surfaceOptions,
8791
+ center: meshCenter,
8792
+ rotationX,
8793
+ rotationY,
8794
+ sceneCenterX,
8795
+ sceneCenterY,
8796
+ size,
8797
+ palette,
8798
+ });
8799
+ drawProjectedOrganicEye(context, sampleContinuousOctopusSurfacePoint(surfaceOptions, eyeLatitude, -eyeLongitude), eyeRadiusX, eyeRadiusY, meshCenter, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, timeMs, animationPhase + eyeRandom() * 0.7, interaction, morphologyProfile.face.eyeStyle);
8800
+ drawProjectedOrganicEye(context, sampleContinuousOctopusSurfacePoint(surfaceOptions, eyeLatitude, eyeLongitude), eyeRadiusX, eyeRadiusY, meshCenter, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, timeMs, animationPhase + 0.85 + eyeRandom() * 0.7, interaction, morphologyProfile.face.eyeStyle);
8801
+ drawProjectedOrganicMouth(context, [
8802
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthLatitude, mouthCenterLongitude - mouthHalfLongitude),
8803
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthCurveLatitude, mouthCenterLongitude),
8804
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthLatitude, mouthCenterLongitude + mouthHalfLongitude),
8805
+ ], meshCenter, rotationX, rotationY, sceneCenterX, sceneCenterY, palette, size);
8806
+ },
8807
+ };
8808
+ /**
8809
+ * Creates seeded tentacle-lobe profiles around the visible lower octopus body.
8810
+ *
8811
+ * @private helper of `octopus3d3AvatarVisual`
8812
+ */
8813
+ function createContinuousTentacleProfiles(createRandom, morphologyProfile) {
8814
+ return Array.from({ length: OCTOPUS_TENTACLE_COUNT }, (_, tentacleIndex) => {
8815
+ const tentacleRandom = createRandom(`octopus3d3-tentacle-${tentacleIndex}`);
8816
+ const progress = tentacleIndex / (OCTOPUS_TENTACLE_COUNT - 1);
8817
+ return {
8818
+ centerLongitude: -Math.PI * 0.86 +
8819
+ progress * Math.PI * 1.72 +
8820
+ (tentacleRandom() - 0.5) * (0.08 + morphologyProfile.tentacles.rootSpreadScale * 0.03),
8821
+ widthScale: 0.86 + tentacleRandom() * 0.34 + (morphologyProfile.tentacles.baseWidthScale - 1) * 0.16,
8822
+ lengthScale: 0.86 + tentacleRandom() * 0.36 + (morphologyProfile.tentacles.flowLengthScale - 1) * 0.22,
8823
+ swayScale: 0.82 + tentacleRandom() * 0.38 + (morphologyProfile.tentacles.swayScale - 1) * 0.2,
8824
+ depthScale: 0.86 + tentacleRandom() * 0.32 + (morphologyProfile.tentacles.tipReachScale - 1) * 0.2,
8825
+ phase: tentacleRandom() * Math.PI * 2,
8826
+ suckerSide: tentacleRandom() > 0.5 ? 1 : -1,
8827
+ };
8828
+ });
8829
+ }
8830
+ /**
8831
+ * Draws the soft underwater atmosphere behind the continuous octopus mesh.
8832
+ *
8833
+ * @private helper of `octopus3d3AvatarVisual`
8834
+ */
8835
+ function drawContinuousOctopusAtmosphere(context, size, palette, sceneCenterX, sceneCenterY, interaction, timeMs) {
8836
+ const glowGradient = context.createRadialGradient(sceneCenterX + interaction.gazeX * size * 0.11, sceneCenterY - size * 0.17 + interaction.gazeY * size * 0.05, size * 0.04, sceneCenterX, sceneCenterY, size * (0.66 + interaction.intensity * 0.02));
8837
+ glowGradient.addColorStop(0, `${palette.highlight}66`);
8838
+ glowGradient.addColorStop(0.34, `${palette.accent}2e`);
8839
+ glowGradient.addColorStop(1, `${palette.highlight}00`);
8840
+ context.fillStyle = glowGradient;
8841
+ context.fillRect(0, 0, size, size);
8842
+ const lowerGradient = context.createRadialGradient(sceneCenterX + Math.sin(timeMs / 1550) * size * 0.05, sceneCenterY + size * 0.29, size * 0.06, sceneCenterX, sceneCenterY + size * 0.3, size * 0.54);
8843
+ lowerGradient.addColorStop(0, `${palette.secondary}25`);
8844
+ lowerGradient.addColorStop(1, `${palette.secondary}00`);
8845
+ context.fillStyle = lowerGradient;
8846
+ context.fillRect(0, 0, size, size);
8847
+ }
8848
+ /**
8849
+ * Draws the soft lower shadow that anchors the octopus in the avatar frame.
8850
+ *
8851
+ * @private helper of `octopus3d3AvatarVisual`
8852
+ */
8853
+ function drawContinuousOctopusShadow(context, size, palette, interaction, timeMs, morphologyProfile) {
8854
+ context.save();
8855
+ context.fillStyle = `${palette.shadow}66`;
8856
+ context.filter = `blur(${size * 0.025}px)`;
8857
+ context.beginPath();
8858
+ context.ellipse(size * 0.5 + interaction.gazeX * size * 0.045, size * 0.9 + Math.sin(timeMs / 980) * size * 0.007, size * (0.19 + morphologyProfile.tentacles.rootSpreadScale * 0.022 + interaction.intensity * 0.02), size * 0.06, 0, 0, Math.PI * 2);
8859
+ context.fill();
8860
+ context.restore();
8861
+ }
8862
+ /**
8863
+ * Resolves visible projected patches for the continuous octopus mesh.
8864
+ *
8865
+ * @private helper of `octopus3d3AvatarVisual`
8866
+ */
8867
+ function resolveVisibleContinuousOctopusPatches(options) {
8868
+ const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
8869
+ const latitudePatchCount = 16;
8870
+ const longitudePatchCount = 40;
8871
+ const surfacePatches = [];
8872
+ for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
8873
+ const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
8874
+ const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
8875
+ const centerLatitude = (startLatitude + endLatitude) / 2;
8876
+ const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
8877
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
8878
+ const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
8879
+ const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
8880
+ const centerLongitude = (startLongitude + endLongitude) / 2;
8881
+ const localCorners = [
8882
+ sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
8883
+ sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
8884
+ sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
8885
+ sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
8886
+ ];
8887
+ const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
8888
+ const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
8889
+ if (surfaceNormal.z <= 0.008) {
8890
+ continue;
8891
+ }
8892
+ const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
8893
+ const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
8894
+ const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
8895
+ surfacePatches.push({
8896
+ corners: projectedCorners,
8897
+ averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
8898
+ transformedCorners.length,
8899
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
8900
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
8901
+ outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
8902
+ });
8903
+ }
8904
+ }
8905
+ return surfacePatches;
8906
+ }
8907
+ /**
8908
+ * Samples one point on the continuous Octopus 3D 3 surface.
8909
+ *
8910
+ * The lower hemisphere is pulled into eight seeded waving lobes, so the portrait reads as
8911
+ * tentacled while still being rendered as one connected blobby mesh.
8912
+ *
8913
+ * @private helper of `octopus3d3AvatarVisual`
8914
+ */
8915
+ function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
8916
+ const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
8917
+ const cosineLatitude = Math.max(0, Math.cos(latitude));
8918
+ const verticalProgress = (Math.sin(latitude) + 1) / 2;
8919
+ const upperBlend = Math.pow(1 - verticalProgress, 1.28);
8920
+ const lowerBlend = smoothStep(0.38, 1, verticalProgress);
8921
+ const tipBlend = smoothStep(0.68, 1, verticalProgress);
8922
+ const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
8923
+ const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
8924
+ const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
8925
+ const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
8926
+ const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
8927
+ animationPhase * 0.6 +
8928
+ timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
8929
+ (0.018 + morphologyProfile.body.wobbleAmplitudeRatio * 0.8) *
8930
+ (0.3 + lowerBlend * 0.7);
8931
+ const tentacleWave = Math.sin(timeMs / 760 + tentacleInfluence.phase + verticalProgress * 2.4) *
8932
+ lowerBlend *
8933
+ tentacleInfluence.core *
8934
+ tentacleInfluence.swayScale;
8935
+ const horizontalScale = 1.04 +
8936
+ mantleRipple +
8937
+ lowerBlend * (0.16 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.1) +
8938
+ lowerBlend * tentacleInfluence.core * (0.2 + lowerLobeWave * 0.12) -
8939
+ upperBlend * 0.08;
8940
+ const depthScale = 1.06 +
8941
+ upperBlend * 0.16 +
8942
+ Math.max(0, Math.cos(effectiveLongitude)) * 0.1 +
8943
+ lowerBlend * tentacleInfluence.core * (0.1 + tentacleInfluence.depthScale * 0.06) -
8944
+ Math.max(0, -Math.cos(effectiveLongitude)) * 0.05;
8945
+ const tentacleTubeRadius = lowerBlend *
8946
+ tentacleInfluence.core *
8947
+ (0.11 + tipBlend * 0.06 + tentacleInfluence.widthScale * 0.025) *
8948
+ radiusX;
8949
+ const planarRadiusX = cosineLatitude * radiusX * horizontalScale + tentacleTubeRadius;
8950
+ const planarRadiusZ = cosineLatitude * radiusZ * depthScale + tentacleTubeRadius * 0.72;
8951
+ const lowerDrop = lowerBlend *
8952
+ radiusY *
8953
+ (0.18 +
8954
+ tentacleInfluence.core *
8955
+ (0.38 +
8956
+ tentacleInfluence.lengthScale * 0.22 +
8957
+ (morphologyProfile.tentacles.flowLengthScale - 1) * 0.08));
8958
+ return {
8959
+ x: Math.sin(effectiveLongitude) * planarRadiusX +
8960
+ tentacleWave * radiusX * (0.052 + tipBlend * 0.05),
8961
+ y: Math.sin(latitude) * radiusY * (1 + upperBlend * 0.12) -
8962
+ upperBlend * radiusY * 0.1 +
8963
+ lowerDrop +
8964
+ Math.sin(timeMs / 1420 + animationPhase + latitude * 1.6) * lowerBlend * radiusY * 0.018 +
8965
+ Math.cos(timeMs / 880 + tentacleInfluence.phase) *
8966
+ lowerBlend *
8967
+ tipBlend *
8968
+ tentacleInfluence.core *
8969
+ radiusY *
8970
+ 0.034,
8971
+ z: Math.cos(effectiveLongitude) * planarRadiusZ +
8972
+ Math.cos(timeMs / 980 + tentacleInfluence.phase + verticalProgress) *
8973
+ lowerBlend *
8974
+ tentacleInfluence.core *
8975
+ radiusZ *
8976
+ 0.04,
8977
+ };
8978
+ }
8979
+ /**
8980
+ * Blends nearby seeded tentacle profiles at one mesh longitude.
8981
+ *
8982
+ * @private helper of `octopus3d3AvatarVisual`
8983
+ */
8984
+ function resolveContinuousTentacleInfluence(options, longitude) {
8985
+ let totalWeight = 0;
8986
+ let weightedSin = 0;
8987
+ let weightedCos = 0;
8988
+ let weightedWidthScale = 0;
8989
+ let weightedLengthScale = 0;
8990
+ let weightedSwayScale = 0;
8991
+ let weightedDepthScale = 0;
8992
+ let weightedPhase = 0;
8993
+ for (const tentacleProfile of options.tentacleProfiles) {
8994
+ const distance = Math.abs(resolveSignedAngularDistance(longitude, tentacleProfile.centerLongitude));
8995
+ const width = 0.2 * tentacleProfile.widthScale;
8996
+ const weight = Math.exp(-(distance * distance) / (width * width));
8997
+ totalWeight += weight;
8998
+ weightedSin += Math.sin(tentacleProfile.centerLongitude) * weight;
8999
+ weightedCos += Math.cos(tentacleProfile.centerLongitude) * weight;
9000
+ weightedWidthScale += tentacleProfile.widthScale * weight;
9001
+ weightedLengthScale += tentacleProfile.lengthScale * weight;
9002
+ weightedSwayScale += tentacleProfile.swayScale * weight;
9003
+ weightedDepthScale += tentacleProfile.depthScale * weight;
9004
+ weightedPhase += tentacleProfile.phase * weight;
9005
+ }
9006
+ if (totalWeight < 0.0001) {
9007
+ return {
9008
+ core: 0,
9009
+ centerLongitude: longitude,
9010
+ widthScale: 1,
9011
+ lengthScale: 1,
9012
+ swayScale: 1,
9013
+ depthScale: 1,
9014
+ phase: 0,
9015
+ };
9016
+ }
9017
+ return {
9018
+ core: clampNumber$1(totalWeight, 0, 1),
9019
+ centerLongitude: Math.atan2(weightedSin / totalWeight, weightedCos / totalWeight),
9020
+ widthScale: weightedWidthScale / totalWeight,
9021
+ lengthScale: weightedLengthScale / totalWeight,
9022
+ swayScale: weightedSwayScale / totalWeight,
9023
+ depthScale: weightedDepthScale / totalWeight,
9024
+ phase: weightedPhase / totalWeight,
9025
+ };
9026
+ }
9027
+ /**
9028
+ * Resolves the soft lower wave that makes the continuous mesh read as a set of tentacles.
9029
+ *
9030
+ * @private helper of `octopus3d3AvatarVisual`
9031
+ */
9032
+ function resolveContinuousLobeWave(options, longitude) {
9033
+ const { morphologyProfile, animationPhase, timeMs } = options;
9034
+ return (Math.cos(longitude * OCTOPUS_TENTACLE_COUNT + animationPhase + timeMs / (980 + morphologyProfile.body.lobeCount * 18)) +
9035
+ 1) / 2;
9036
+ }
9037
+ /**
9038
+ * Resolves one base fill tone for a patch on the continuous octopus mesh.
9039
+ *
9040
+ * @private helper of `octopus3d3AvatarVisual`
9041
+ */
9042
+ function resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, forwardness, tentacleCore, lowerLobeWave) {
9043
+ const tonalProgress = clampNumber$1(verticalProgress + lowerLobeWave * 0.1 + tentacleCore * 0.08 - forwardness * 0.08, 0, 1);
9044
+ if (tonalProgress < 0.14) {
9045
+ return palette.highlight;
9046
+ }
9047
+ if (tonalProgress < 0.32) {
9048
+ return palette.secondary;
9049
+ }
9050
+ if (tonalProgress < 0.72) {
9051
+ return forwardness > 0.55 ? palette.secondary : palette.primary;
9052
+ }
9053
+ return tentacleCore > 0.44 ? `${palette.primary}f4` : `${palette.shadow}ee`;
9054
+ }
9055
+ /**
9056
+ * Draws one projected mesh patch with soft shading and a subtle edge.
9057
+ *
9058
+ * @private helper of `octopus3d3AvatarVisual`
9059
+ */
9060
+ function drawContinuousSurfacePatch(context, surfacePatch) {
9061
+ drawProjectedQuad(context, surfacePatch.corners, surfacePatch.fillStyle);
9062
+ if (surfacePatch.lightIntensity > 0) {
9063
+ drawProjectedQuad(context, surfacePatch.corners, `rgba(255, 255, 255, ${0.18 * surfacePatch.lightIntensity})`);
9064
+ }
9065
+ else if (surfacePatch.lightIntensity < 0) {
9066
+ drawProjectedQuad(context, surfacePatch.corners, `rgba(0, 0, 0, ${0.25 * Math.abs(surfacePatch.lightIntensity)})`);
9067
+ }
9068
+ context.save();
9069
+ context.beginPath();
9070
+ context.moveTo(surfacePatch.corners[0].x, surfacePatch.corners[0].y);
9071
+ for (let cornerIndex = 1; cornerIndex < surfacePatch.corners.length; cornerIndex++) {
9072
+ context.lineTo(surfacePatch.corners[cornerIndex].x, surfacePatch.corners[cornerIndex].y);
9073
+ }
9074
+ context.closePath();
9075
+ context.strokeStyle = surfacePatch.outlineColor;
9076
+ context.lineWidth = Math.max(0.7, getProjectedQuadPerimeter(surfacePatch.corners) * 0.0032);
9077
+ context.lineJoin = 'round';
9078
+ context.stroke();
9079
+ context.restore();
9080
+ }
9081
+ /**
9082
+ * Draws projected mantle-current lines on the front of the mesh.
9083
+ *
9084
+ * @private helper of `octopus3d3AvatarVisual`
9085
+ */
9086
+ function drawProjectedSurfaceCurrents(options) {
9087
+ const { context, surfaceOptions, center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, timeMs, animationPhase, } = options;
9088
+ const currentCount = Math.min(6, morphologyProfile.details.mantleCurrentCount);
9089
+ const centerIndex = (currentCount - 1) / 2;
9090
+ context.save();
9091
+ context.lineCap = 'round';
9092
+ context.lineJoin = 'round';
9093
+ for (let currentIndex = 0; currentIndex < currentCount; currentIndex++) {
9094
+ const baseLongitude = (currentIndex - centerIndex) * 0.15;
9095
+ const projectedPoints = [];
9096
+ for (let sampleIndex = 0; sampleIndex < 8; sampleIndex++) {
9097
+ const progress = sampleIndex / 7;
9098
+ const latitude = -0.46 + progress * 0.74;
9099
+ const longitude = baseLongitude +
9100
+ Math.sin(timeMs / 1160 + animationPhase + currentIndex * 0.7 + progress * 2) * 0.035;
9101
+ const scenePoint = transformScenePoint(sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude), center, rotationX, rotationY);
9102
+ if (scenePoint.z > center.z - size * 0.016) {
9103
+ projectedPoints.push(projectScenePoint(scenePoint, size, sceneCenterX, sceneCenterY));
9104
+ }
9105
+ }
9106
+ if (projectedPoints.length < 3) {
9107
+ continue;
9108
+ }
9109
+ context.beginPath();
9110
+ context.moveTo(projectedPoints[0].x, projectedPoints[0].y);
9111
+ for (const projectedPoint of projectedPoints.slice(1)) {
9112
+ context.lineTo(projectedPoint.x, projectedPoint.y);
9113
+ }
9114
+ context.strokeStyle = currentIndex % 2 === 0 ? `${palette.highlight}3d` : `${palette.accent}33`;
9115
+ context.lineWidth = size * (0.0055 + currentIndex * 0.00045);
9116
+ context.stroke();
9117
+ }
9118
+ context.restore();
9119
+ }
9120
+ /**
9121
+ * Draws small projected sucker highlights on the waving lower mesh lobes.
9122
+ *
9123
+ * @private helper of `octopus3d3AvatarVisual`
9124
+ */
9125
+ function drawProjectedTentacleSuckers(options) {
9126
+ const { surfaceOptions, size } = options;
9127
+ const { timeMs } = surfaceOptions;
9128
+ for (const tentacleProfile of surfaceOptions.tentacleProfiles) {
9129
+ if (Math.cos(tentacleProfile.centerLongitude) < -0.12) {
9130
+ continue;
9131
+ }
9132
+ for (let suckerIndex = 0; suckerIndex < 3; suckerIndex++) {
9133
+ const latitude = 0.52 + suckerIndex * 0.14;
9134
+ const sideOffset = tentacleProfile.suckerSide * (0.035 + suckerIndex * 0.012) * tentacleProfile.widthScale;
9135
+ const waveOffset = Math.sin(timeMs / 900 + tentacleProfile.phase + suckerIndex * 0.8) * 0.018;
9136
+ drawProjectedSurfaceSpot({
9137
+ ...options,
9138
+ latitude,
9139
+ longitude: tentacleProfile.centerLongitude + sideOffset + waveOffset,
9140
+ radiusScale: size * (0.0065 - suckerIndex * 0.0007),
9141
+ });
9142
+ }
9143
+ }
9144
+ }
9145
+ /**
9146
+ * Draws one tiny projected surface spot by sampling local mesh tangents.
9147
+ *
9148
+ * @private helper of `octopus3d3AvatarVisual`
9149
+ */
9150
+ function drawProjectedSurfaceSpot(options) {
9151
+ const { context, surfaceOptions, center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, latitude, longitude, radiusScale, } = options;
9152
+ const localCenter = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude);
9153
+ const localHorizontal = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude + 0.018);
9154
+ const localVertical = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude + 0.018, longitude);
9155
+ const sceneCenterPoint = transformScenePoint(localCenter, center, rotationX, rotationY);
9156
+ if (sceneCenterPoint.z <= center.z - size * 0.012) {
9157
+ return;
9158
+ }
9159
+ const projectedCenterPoint = projectScenePoint(sceneCenterPoint, size, sceneCenterX, sceneCenterY);
9160
+ const projectedHorizontalPoint = projectScenePoint(transformScenePoint(localHorizontal, center, rotationX, rotationY), size, sceneCenterX, sceneCenterY);
9161
+ const projectedVerticalPoint = projectScenePoint(transformScenePoint(localVertical, center, rotationX, rotationY), size, sceneCenterX, sceneCenterY);
9162
+ const horizontalRadius = clampNumber$1(Math.hypot(projectedHorizontalPoint.x - projectedCenterPoint.x, projectedHorizontalPoint.y - projectedCenterPoint.y) *
9163
+ radiusScale *
9164
+ 0.74, size * 0.003, size * 0.018);
9165
+ const verticalRadius = clampNumber$1(Math.hypot(projectedVerticalPoint.x - projectedCenterPoint.x, projectedVerticalPoint.y - projectedCenterPoint.y) *
9166
+ radiusScale *
9167
+ 0.52, size * 0.0024, size * 0.014);
9168
+ const rotation = Math.atan2(projectedHorizontalPoint.y - projectedCenterPoint.y, projectedHorizontalPoint.x - projectedCenterPoint.x);
9169
+ context.save();
9170
+ context.translate(projectedCenterPoint.x, projectedCenterPoint.y);
9171
+ context.rotate(rotation);
9172
+ context.beginPath();
9173
+ context.ellipse(0, 0, horizontalRadius, verticalRadius, 0, 0, Math.PI * 2);
9174
+ context.fillStyle = `${palette.highlight}73`;
9175
+ context.fill();
9176
+ context.strokeStyle = `${palette.highlight}99`;
9177
+ context.lineWidth = Math.max(0.7, size * 0.0028);
9178
+ context.stroke();
9179
+ context.restore();
9180
+ }
9181
+ /**
9182
+ * Resolves a signed angular distance from the source longitude to the target longitude.
9183
+ *
9184
+ * @private helper of `octopus3d3AvatarVisual`
9185
+ */
9186
+ function resolveSignedAngularDistance(sourceLongitude, targetLongitude) {
9187
+ return Math.atan2(Math.sin(targetLongitude - sourceLongitude), Math.cos(targetLongitude - sourceLongitude));
9188
+ }
9189
+ /**
9190
+ * Smoothly maps a value between two bounds into `[0, 1]`.
9191
+ *
9192
+ * @private helper of `octopus3d3AvatarVisual`
9193
+ */
9194
+ function smoothStep(edgeStart, edgeEnd, value) {
9195
+ const progress = clampNumber$1((value - edgeStart) / (edgeEnd - edgeStart), 0, 1);
9196
+ return progress * progress * (3 - 2 * progress);
9197
+ }
9198
+
8689
9199
  /* eslint-disable no-magic-numbers */
8690
9200
  /**
8691
9201
  * Octopus avatar visual.
@@ -9456,6 +9966,7 @@
9456
9966
  octopus3AvatarVisual,
9457
9967
  octopus3dAvatarVisual,
9458
9968
  octopus3d2AvatarVisual,
9969
+ octopus3d3AvatarVisual,
9459
9970
  asciiOctopusAvatarVisual,
9460
9971
  minecraftAvatarVisual,
9461
9972
  minecraft2AvatarVisual,