@promptbook/wizard 0.112.0-103 → 0.112.0-105

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 CHANGED
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-103';
41
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-105';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -22570,7 +22570,7 @@ function fillTextureRect(texture, x, y, width, height, color) {
22570
22570
  *
22571
22571
  * @private helper of `minecraft2AvatarVisual`
22572
22572
  */
22573
- const LIGHT_DIRECTION$2 = normalizeVector3({
22573
+ const LIGHT_DIRECTION$3 = normalizeVector3({
22574
22574
  x: 0.4,
22575
22575
  y: -0.65,
22576
22576
  z: 0.92,
@@ -22782,7 +22782,7 @@ function resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY) {
22782
22782
  corners: projectedCorners,
22783
22783
  texture: faceDefinition.texture,
22784
22784
  averageDepth: transformedCorners.reduce((depthSum, corner) => depthSum + corner.z, 0) / transformedCorners.length,
22785
- lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION$2), -1, 1),
22785
+ lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION$3), -1, 1),
22786
22786
  outlineColor: cuboid.outlineColor,
22787
22787
  };
22788
22788
  });
@@ -23973,7 +23973,7 @@ function formatAlphaHex(opacity) {
23973
23973
  *
23974
23974
  * @private helper of `octopus3dAvatarVisual`
23975
23975
  */
23976
- const LIGHT_DIRECTION$1 = normalizeVector3({
23976
+ const LIGHT_DIRECTION$2 = normalizeVector3({
23977
23977
  x: 0.48,
23978
23978
  y: -0.62,
23979
23979
  z: 0.94,
@@ -24183,7 +24183,7 @@ function resolveVisibleEllipsoidPatches(options) {
24183
24183
  corners: projectedCorners,
24184
24184
  averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
24185
24185
  transformedCorners.length,
24186
- lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
24186
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$2), -1, 1),
24187
24187
  fillStyle: resolveSurfacePatchFillStyle(palette, verticalProgress + verticalColorBias),
24188
24188
  outlineColor,
24189
24189
  });
@@ -24372,7 +24372,7 @@ function resolveEllipsoidSurfaceDepth(radiusX, radiusY, radiusZ, x, y) {
24372
24372
  *
24373
24373
  * @private helper of `octopus3d2AvatarVisual`
24374
24374
  */
24375
- const LIGHT_DIRECTION = normalizeVector3({
24375
+ const LIGHT_DIRECTION$1 = normalizeVector3({
24376
24376
  x: 0.38,
24377
24377
  y: -0.6,
24378
24378
  z: 0.98,
@@ -24521,7 +24521,7 @@ function resolveVisibleBlobbyOctopusPatches(options) {
24521
24521
  corners: projectedCorners,
24522
24522
  averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
24523
24523
  transformedCorners.length,
24524
- lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
24524
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
24525
24525
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
24526
24526
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
24527
24527
  });
@@ -24621,6 +24621,514 @@ function drawBlobbySurfacePatch(context, surfacePatch) {
24621
24621
  context.restore();
24622
24622
  }
24623
24623
 
24624
+ /* eslint-disable no-magic-numbers */
24625
+ /**
24626
+ * Light direction used by the continuous octopus mesh shading.
24627
+ *
24628
+ * @private helper of `octopus3d3AvatarVisual`
24629
+ */
24630
+ const LIGHT_DIRECTION = normalizeVector3({
24631
+ x: 0.34,
24632
+ y: -0.62,
24633
+ z: 1,
24634
+ });
24635
+ /**
24636
+ * Real-octopus tentacle count used by the continuous lower mesh.
24637
+ *
24638
+ * @private helper of `octopus3d3AvatarVisual`
24639
+ */
24640
+ const OCTOPUS_TENTACLE_COUNT = 8;
24641
+ /**
24642
+ * Octopus 3D 3 avatar visual.
24643
+ *
24644
+ * @private built-in avatar visual
24645
+ */
24646
+ const octopus3d3AvatarVisual = {
24647
+ id: 'octopus3d3',
24648
+ title: 'Octopus 3D 3',
24649
+ description: 'Cute continuous 3D octopus with a blobby single mesh, waving tentacle lobes, rich shading, and cursor-aware eyes.',
24650
+ isAnimated: true,
24651
+ supportsPointerTracking: true,
24652
+ render({ context, size, palette, createRandom, timeMs, interaction }) {
24653
+ const morphologyProfile = createOctopus3MorphologyProfile(createRandom);
24654
+ const animationRandom = createRandom('octopus3d3-animation-profile');
24655
+ const eyeRandom = createRandom('octopus3d3-eye-profile');
24656
+ const animationPhase = animationRandom() * Math.PI * 2;
24657
+ const tentacleProfiles = createContinuousTentacleProfiles(createRandom, morphologyProfile);
24658
+ const sceneCenterX = size * 0.5;
24659
+ const sceneCenterY = size * 0.535;
24660
+ const bob = Math.sin(timeMs / 960 + animationPhase) * size * 0.012;
24661
+ const meshCenter = {
24662
+ x: interaction.bodyOffsetX * size * 0.048 + size * morphologyProfile.body.centerXJitterRatio * 0.44,
24663
+ y: -size * 0.07 + interaction.bodyOffsetY * size * 0.026 + bob,
24664
+ z: interaction.intensity * size * 0.018,
24665
+ };
24666
+ const rotationY = -0.1 +
24667
+ Math.sin(timeMs / 2700 + animationPhase) * 0.035 +
24668
+ interaction.bodyOffsetX * 0.22 +
24669
+ interaction.gazeX * 0.88;
24670
+ const rotationX = -0.07 +
24671
+ Math.cos(timeMs / 3100 + animationPhase * 0.7) * 0.018 -
24672
+ interaction.bodyOffsetY * 0.08 -
24673
+ interaction.gazeY * 0.38;
24674
+ const surfaceOptions = {
24675
+ radiusX: size * morphologyProfile.body.bodyRadiusRatio * morphologyProfile.body.horizontalStretch * 1.1,
24676
+ radiusY: size * morphologyProfile.body.bodyRadiusRatio * morphologyProfile.body.verticalStretch * 1.08,
24677
+ radiusZ: size *
24678
+ morphologyProfile.body.bodyRadiusRatio *
24679
+ (1.02 + (morphologyProfile.body.horizontalStretch - 1) * 0.18),
24680
+ morphologyProfile,
24681
+ timeMs,
24682
+ animationPhase,
24683
+ tentacleProfiles,
24684
+ };
24685
+ const surfacePatches = resolveVisibleContinuousOctopusPatches({
24686
+ ...surfaceOptions,
24687
+ center: meshCenter,
24688
+ rotationX,
24689
+ rotationY,
24690
+ sceneCenterX,
24691
+ sceneCenterY,
24692
+ size,
24693
+ palette,
24694
+ });
24695
+ const eyeLatitude = clampNumber$1(morphologyProfile.face.eyeCenterYOffsetRatio * 4.2 - 0.03, -0.22, 0.08);
24696
+ const eyeLongitude = clampNumber$1(morphologyProfile.face.eyeSpacingRatio * 3.1, 0.18, 0.32);
24697
+ const mouthLatitude = clampNumber$1(eyeLatitude + 0.2 + morphologyProfile.face.mouthYOffsetRatio, 0.08, 0.34);
24698
+ const mouthCenterLongitude = clampNumber$1(morphologyProfile.face.mouthCenterOffsetRatio * 5.6, -0.08, 0.08);
24699
+ const mouthHalfLongitude = clampNumber$1(eyeLongitude * 0.78, 0.15, 0.28);
24700
+ const mouthCurveLatitude = clampNumber$1(mouthLatitude + morphologyProfile.face.mouthCurveDepthRatio * 0.78, mouthLatitude + 0.03, 0.42);
24701
+ const eyeRadiusX = size * morphologyProfile.face.eyeRadiusXRatio * 0.76;
24702
+ const eyeRadiusY = eyeRadiusX * morphologyProfile.face.eyeHeightRatio * 0.9;
24703
+ drawAvatarFrame(context, size, palette);
24704
+ drawContinuousOctopusAtmosphere(context, size, palette, sceneCenterX, sceneCenterY, interaction, timeMs);
24705
+ drawContinuousOctopusShadow(context, size, palette, interaction, timeMs, morphologyProfile);
24706
+ for (const surfacePatch of surfacePatches.sort((firstSurfacePatch, secondSurfacePatch) => firstSurfacePatch.averageDepth - secondSurfacePatch.averageDepth)) {
24707
+ drawContinuousSurfacePatch(context, surfacePatch);
24708
+ }
24709
+ drawProjectedSurfaceCurrents({
24710
+ context,
24711
+ surfaceOptions,
24712
+ center: meshCenter,
24713
+ rotationX,
24714
+ rotationY,
24715
+ sceneCenterX,
24716
+ sceneCenterY,
24717
+ size,
24718
+ palette,
24719
+ morphologyProfile,
24720
+ timeMs,
24721
+ animationPhase,
24722
+ });
24723
+ drawProjectedTentacleSuckers({
24724
+ context,
24725
+ surfaceOptions,
24726
+ center: meshCenter,
24727
+ rotationX,
24728
+ rotationY,
24729
+ sceneCenterX,
24730
+ sceneCenterY,
24731
+ size,
24732
+ palette,
24733
+ });
24734
+ drawProjectedOrganicEye(context, sampleContinuousOctopusSurfacePoint(surfaceOptions, eyeLatitude, -eyeLongitude), eyeRadiusX, eyeRadiusY, meshCenter, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, timeMs, animationPhase + eyeRandom() * 0.7, interaction, morphologyProfile.face.eyeStyle);
24735
+ 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);
24736
+ drawProjectedOrganicMouth(context, [
24737
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthLatitude, mouthCenterLongitude - mouthHalfLongitude),
24738
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthCurveLatitude, mouthCenterLongitude),
24739
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthLatitude, mouthCenterLongitude + mouthHalfLongitude),
24740
+ ], meshCenter, rotationX, rotationY, sceneCenterX, sceneCenterY, palette, size);
24741
+ },
24742
+ };
24743
+ /**
24744
+ * Creates seeded tentacle-lobe profiles around the visible lower octopus body.
24745
+ *
24746
+ * @private helper of `octopus3d3AvatarVisual`
24747
+ */
24748
+ function createContinuousTentacleProfiles(createRandom, morphologyProfile) {
24749
+ return Array.from({ length: OCTOPUS_TENTACLE_COUNT }, (_, tentacleIndex) => {
24750
+ const tentacleRandom = createRandom(`octopus3d3-tentacle-${tentacleIndex}`);
24751
+ const progress = tentacleIndex / (OCTOPUS_TENTACLE_COUNT - 1);
24752
+ return {
24753
+ centerLongitude: -Math.PI * 0.86 +
24754
+ progress * Math.PI * 1.72 +
24755
+ (tentacleRandom() - 0.5) * (0.08 + morphologyProfile.tentacles.rootSpreadScale * 0.03),
24756
+ widthScale: 0.86 + tentacleRandom() * 0.34 + (morphologyProfile.tentacles.baseWidthScale - 1) * 0.16,
24757
+ lengthScale: 0.86 + tentacleRandom() * 0.36 + (morphologyProfile.tentacles.flowLengthScale - 1) * 0.22,
24758
+ swayScale: 0.82 + tentacleRandom() * 0.38 + (morphologyProfile.tentacles.swayScale - 1) * 0.2,
24759
+ depthScale: 0.86 + tentacleRandom() * 0.32 + (morphologyProfile.tentacles.tipReachScale - 1) * 0.2,
24760
+ phase: tentacleRandom() * Math.PI * 2,
24761
+ suckerSide: tentacleRandom() > 0.5 ? 1 : -1,
24762
+ };
24763
+ });
24764
+ }
24765
+ /**
24766
+ * Draws the soft underwater atmosphere behind the continuous octopus mesh.
24767
+ *
24768
+ * @private helper of `octopus3d3AvatarVisual`
24769
+ */
24770
+ function drawContinuousOctopusAtmosphere(context, size, palette, sceneCenterX, sceneCenterY, interaction, timeMs) {
24771
+ 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));
24772
+ glowGradient.addColorStop(0, `${palette.highlight}66`);
24773
+ glowGradient.addColorStop(0.34, `${palette.accent}2e`);
24774
+ glowGradient.addColorStop(1, `${palette.highlight}00`);
24775
+ context.fillStyle = glowGradient;
24776
+ context.fillRect(0, 0, size, size);
24777
+ 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);
24778
+ lowerGradient.addColorStop(0, `${palette.secondary}25`);
24779
+ lowerGradient.addColorStop(1, `${palette.secondary}00`);
24780
+ context.fillStyle = lowerGradient;
24781
+ context.fillRect(0, 0, size, size);
24782
+ }
24783
+ /**
24784
+ * Draws the soft lower shadow that anchors the octopus in the avatar frame.
24785
+ *
24786
+ * @private helper of `octopus3d3AvatarVisual`
24787
+ */
24788
+ function drawContinuousOctopusShadow(context, size, palette, interaction, timeMs, morphologyProfile) {
24789
+ context.save();
24790
+ context.fillStyle = `${palette.shadow}66`;
24791
+ context.filter = `blur(${size * 0.025}px)`;
24792
+ context.beginPath();
24793
+ 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);
24794
+ context.fill();
24795
+ context.restore();
24796
+ }
24797
+ /**
24798
+ * Resolves visible projected patches for the continuous octopus mesh.
24799
+ *
24800
+ * @private helper of `octopus3d3AvatarVisual`
24801
+ */
24802
+ function resolveVisibleContinuousOctopusPatches(options) {
24803
+ const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
24804
+ const latitudePatchCount = 16;
24805
+ const longitudePatchCount = 40;
24806
+ const surfacePatches = [];
24807
+ for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
24808
+ const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
24809
+ const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
24810
+ const centerLatitude = (startLatitude + endLatitude) / 2;
24811
+ const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
24812
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
24813
+ const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
24814
+ const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
24815
+ const centerLongitude = (startLongitude + endLongitude) / 2;
24816
+ const localCorners = [
24817
+ sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
24818
+ sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
24819
+ sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
24820
+ sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
24821
+ ];
24822
+ const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
24823
+ const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
24824
+ if (surfaceNormal.z <= 0.008) {
24825
+ continue;
24826
+ }
24827
+ const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
24828
+ const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
24829
+ const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
24830
+ surfacePatches.push({
24831
+ corners: projectedCorners,
24832
+ averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
24833
+ transformedCorners.length,
24834
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
24835
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
24836
+ outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
24837
+ });
24838
+ }
24839
+ }
24840
+ return surfacePatches;
24841
+ }
24842
+ /**
24843
+ * Samples one point on the continuous Octopus 3D 3 surface.
24844
+ *
24845
+ * The lower hemisphere is pulled into eight seeded waving lobes, so the portrait reads as
24846
+ * tentacled while still being rendered as one connected blobby mesh.
24847
+ *
24848
+ * @private helper of `octopus3d3AvatarVisual`
24849
+ */
24850
+ function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
24851
+ const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
24852
+ const cosineLatitude = Math.max(0, Math.cos(latitude));
24853
+ const verticalProgress = (Math.sin(latitude) + 1) / 2;
24854
+ const upperBlend = Math.pow(1 - verticalProgress, 1.28);
24855
+ const lowerBlend = smoothStep(0.38, 1, verticalProgress);
24856
+ const tipBlend = smoothStep(0.68, 1, verticalProgress);
24857
+ const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
24858
+ const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
24859
+ const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
24860
+ const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
24861
+ const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
24862
+ animationPhase * 0.6 +
24863
+ timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
24864
+ (0.018 + morphologyProfile.body.wobbleAmplitudeRatio * 0.8) *
24865
+ (0.3 + lowerBlend * 0.7);
24866
+ const tentacleWave = Math.sin(timeMs / 760 + tentacleInfluence.phase + verticalProgress * 2.4) *
24867
+ lowerBlend *
24868
+ tentacleInfluence.core *
24869
+ tentacleInfluence.swayScale;
24870
+ const horizontalScale = 1.04 +
24871
+ mantleRipple +
24872
+ lowerBlend * (0.16 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.1) +
24873
+ lowerBlend * tentacleInfluence.core * (0.2 + lowerLobeWave * 0.12) -
24874
+ upperBlend * 0.08;
24875
+ const depthScale = 1.06 +
24876
+ upperBlend * 0.16 +
24877
+ Math.max(0, Math.cos(effectiveLongitude)) * 0.1 +
24878
+ lowerBlend * tentacleInfluence.core * (0.1 + tentacleInfluence.depthScale * 0.06) -
24879
+ Math.max(0, -Math.cos(effectiveLongitude)) * 0.05;
24880
+ const tentacleTubeRadius = lowerBlend * tentacleInfluence.core * (0.11 + tipBlend * 0.06 + tentacleInfluence.widthScale * 0.025) * radiusX;
24881
+ const planarRadiusX = cosineLatitude * radiusX * horizontalScale + tentacleTubeRadius;
24882
+ const planarRadiusZ = cosineLatitude * radiusZ * depthScale + tentacleTubeRadius * 0.72;
24883
+ const lowerDrop = lowerBlend *
24884
+ radiusY *
24885
+ (0.18 +
24886
+ tentacleInfluence.core *
24887
+ (0.38 +
24888
+ tentacleInfluence.lengthScale * 0.22 +
24889
+ (morphologyProfile.tentacles.flowLengthScale - 1) * 0.08));
24890
+ return {
24891
+ x: Math.sin(effectiveLongitude) * planarRadiusX + tentacleWave * radiusX * (0.052 + tipBlend * 0.05),
24892
+ y: Math.sin(latitude) * radiusY * (1 + upperBlend * 0.12) -
24893
+ upperBlend * radiusY * 0.1 +
24894
+ lowerDrop +
24895
+ Math.sin(timeMs / 1420 + animationPhase + latitude * 1.6) * lowerBlend * radiusY * 0.018 +
24896
+ Math.cos(timeMs / 880 + tentacleInfluence.phase) *
24897
+ lowerBlend *
24898
+ tipBlend *
24899
+ tentacleInfluence.core *
24900
+ radiusY *
24901
+ 0.034,
24902
+ z: Math.cos(effectiveLongitude) * planarRadiusZ +
24903
+ Math.cos(timeMs / 980 + tentacleInfluence.phase + verticalProgress) *
24904
+ lowerBlend *
24905
+ tentacleInfluence.core *
24906
+ radiusZ *
24907
+ 0.04,
24908
+ };
24909
+ }
24910
+ /**
24911
+ * Blends nearby seeded tentacle profiles at one mesh longitude.
24912
+ *
24913
+ * @private helper of `octopus3d3AvatarVisual`
24914
+ */
24915
+ function resolveContinuousTentacleInfluence(options, longitude) {
24916
+ let totalWeight = 0;
24917
+ let weightedSin = 0;
24918
+ let weightedCos = 0;
24919
+ let weightedWidthScale = 0;
24920
+ let weightedLengthScale = 0;
24921
+ let weightedSwayScale = 0;
24922
+ let weightedDepthScale = 0;
24923
+ let weightedPhase = 0;
24924
+ for (const tentacleProfile of options.tentacleProfiles) {
24925
+ const distance = Math.abs(resolveSignedAngularDistance(longitude, tentacleProfile.centerLongitude));
24926
+ const width = 0.2 * tentacleProfile.widthScale;
24927
+ const weight = Math.exp(-(distance * distance) / (width * width));
24928
+ totalWeight += weight;
24929
+ weightedSin += Math.sin(tentacleProfile.centerLongitude) * weight;
24930
+ weightedCos += Math.cos(tentacleProfile.centerLongitude) * weight;
24931
+ weightedWidthScale += tentacleProfile.widthScale * weight;
24932
+ weightedLengthScale += tentacleProfile.lengthScale * weight;
24933
+ weightedSwayScale += tentacleProfile.swayScale * weight;
24934
+ weightedDepthScale += tentacleProfile.depthScale * weight;
24935
+ weightedPhase += tentacleProfile.phase * weight;
24936
+ }
24937
+ if (totalWeight < 0.0001) {
24938
+ return {
24939
+ core: 0,
24940
+ centerLongitude: longitude,
24941
+ widthScale: 1,
24942
+ lengthScale: 1,
24943
+ swayScale: 1,
24944
+ depthScale: 1,
24945
+ phase: 0,
24946
+ };
24947
+ }
24948
+ return {
24949
+ core: clampNumber$1(totalWeight, 0, 1),
24950
+ centerLongitude: Math.atan2(weightedSin / totalWeight, weightedCos / totalWeight),
24951
+ widthScale: weightedWidthScale / totalWeight,
24952
+ lengthScale: weightedLengthScale / totalWeight,
24953
+ swayScale: weightedSwayScale / totalWeight,
24954
+ depthScale: weightedDepthScale / totalWeight,
24955
+ phase: weightedPhase / totalWeight,
24956
+ };
24957
+ }
24958
+ /**
24959
+ * Resolves the soft lower wave that makes the continuous mesh read as a set of tentacles.
24960
+ *
24961
+ * @private helper of `octopus3d3AvatarVisual`
24962
+ */
24963
+ function resolveContinuousLobeWave(options, longitude) {
24964
+ const { morphologyProfile, animationPhase, timeMs } = options;
24965
+ return ((Math.cos(longitude * OCTOPUS_TENTACLE_COUNT +
24966
+ animationPhase +
24967
+ timeMs / (980 + morphologyProfile.body.lobeCount * 18)) +
24968
+ 1) /
24969
+ 2);
24970
+ }
24971
+ /**
24972
+ * Resolves one base fill tone for a patch on the continuous octopus mesh.
24973
+ *
24974
+ * @private helper of `octopus3d3AvatarVisual`
24975
+ */
24976
+ function resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, forwardness, tentacleCore, lowerLobeWave) {
24977
+ const tonalProgress = clampNumber$1(verticalProgress + lowerLobeWave * 0.1 + tentacleCore * 0.08 - forwardness * 0.08, 0, 1);
24978
+ if (tonalProgress < 0.14) {
24979
+ return palette.highlight;
24980
+ }
24981
+ if (tonalProgress < 0.32) {
24982
+ return palette.secondary;
24983
+ }
24984
+ if (tonalProgress < 0.72) {
24985
+ return forwardness > 0.55 ? palette.secondary : palette.primary;
24986
+ }
24987
+ return tentacleCore > 0.44 ? `${palette.primary}f4` : `${palette.shadow}ee`;
24988
+ }
24989
+ /**
24990
+ * Draws one projected mesh patch with soft shading and a subtle edge.
24991
+ *
24992
+ * @private helper of `octopus3d3AvatarVisual`
24993
+ */
24994
+ function drawContinuousSurfacePatch(context, surfacePatch) {
24995
+ drawProjectedQuad(context, surfacePatch.corners, surfacePatch.fillStyle);
24996
+ if (surfacePatch.lightIntensity > 0) {
24997
+ drawProjectedQuad(context, surfacePatch.corners, `rgba(255, 255, 255, ${0.18 * surfacePatch.lightIntensity})`);
24998
+ }
24999
+ else if (surfacePatch.lightIntensity < 0) {
25000
+ drawProjectedQuad(context, surfacePatch.corners, `rgba(0, 0, 0, ${0.25 * Math.abs(surfacePatch.lightIntensity)})`);
25001
+ }
25002
+ context.save();
25003
+ context.beginPath();
25004
+ context.moveTo(surfacePatch.corners[0].x, surfacePatch.corners[0].y);
25005
+ for (let cornerIndex = 1; cornerIndex < surfacePatch.corners.length; cornerIndex++) {
25006
+ context.lineTo(surfacePatch.corners[cornerIndex].x, surfacePatch.corners[cornerIndex].y);
25007
+ }
25008
+ context.closePath();
25009
+ context.strokeStyle = surfacePatch.outlineColor;
25010
+ context.lineWidth = Math.max(0.7, getProjectedQuadPerimeter(surfacePatch.corners) * 0.0032);
25011
+ context.lineJoin = 'round';
25012
+ context.stroke();
25013
+ context.restore();
25014
+ }
25015
+ /**
25016
+ * Draws projected mantle-current lines on the front of the mesh.
25017
+ *
25018
+ * @private helper of `octopus3d3AvatarVisual`
25019
+ */
25020
+ function drawProjectedSurfaceCurrents(options) {
25021
+ const { context, surfaceOptions, center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, timeMs, animationPhase, } = options;
25022
+ const currentCount = Math.min(6, morphologyProfile.details.mantleCurrentCount);
25023
+ const centerIndex = (currentCount - 1) / 2;
25024
+ context.save();
25025
+ context.lineCap = 'round';
25026
+ context.lineJoin = 'round';
25027
+ for (let currentIndex = 0; currentIndex < currentCount; currentIndex++) {
25028
+ const baseLongitude = (currentIndex - centerIndex) * 0.15;
25029
+ const projectedPoints = [];
25030
+ for (let sampleIndex = 0; sampleIndex < 8; sampleIndex++) {
25031
+ const progress = sampleIndex / 7;
25032
+ const latitude = -0.46 + progress * 0.74;
25033
+ const longitude = baseLongitude + Math.sin(timeMs / 1160 + animationPhase + currentIndex * 0.7 + progress * 2) * 0.035;
25034
+ const scenePoint = transformScenePoint(sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude), center, rotationX, rotationY);
25035
+ if (scenePoint.z > center.z - size * 0.016) {
25036
+ projectedPoints.push(projectScenePoint(scenePoint, size, sceneCenterX, sceneCenterY));
25037
+ }
25038
+ }
25039
+ if (projectedPoints.length < 3) {
25040
+ continue;
25041
+ }
25042
+ context.beginPath();
25043
+ context.moveTo(projectedPoints[0].x, projectedPoints[0].y);
25044
+ for (const projectedPoint of projectedPoints.slice(1)) {
25045
+ context.lineTo(projectedPoint.x, projectedPoint.y);
25046
+ }
25047
+ context.strokeStyle = currentIndex % 2 === 0 ? `${palette.highlight}3d` : `${palette.accent}33`;
25048
+ context.lineWidth = size * (0.0055 + currentIndex * 0.00045);
25049
+ context.stroke();
25050
+ }
25051
+ context.restore();
25052
+ }
25053
+ /**
25054
+ * Draws small projected sucker highlights on the waving lower mesh lobes.
25055
+ *
25056
+ * @private helper of `octopus3d3AvatarVisual`
25057
+ */
25058
+ function drawProjectedTentacleSuckers(options) {
25059
+ const { surfaceOptions, size } = options;
25060
+ const { timeMs } = surfaceOptions;
25061
+ for (const tentacleProfile of surfaceOptions.tentacleProfiles) {
25062
+ if (Math.cos(tentacleProfile.centerLongitude) < -0.12) {
25063
+ continue;
25064
+ }
25065
+ for (let suckerIndex = 0; suckerIndex < 3; suckerIndex++) {
25066
+ const latitude = 0.52 + suckerIndex * 0.14;
25067
+ const sideOffset = tentacleProfile.suckerSide * (0.035 + suckerIndex * 0.012) * tentacleProfile.widthScale;
25068
+ const waveOffset = Math.sin(timeMs / 900 + tentacleProfile.phase + suckerIndex * 0.8) * 0.018;
25069
+ drawProjectedSurfaceSpot({
25070
+ ...options,
25071
+ latitude,
25072
+ longitude: tentacleProfile.centerLongitude + sideOffset + waveOffset,
25073
+ radiusScale: size * (0.0065 - suckerIndex * 0.0007),
25074
+ });
25075
+ }
25076
+ }
25077
+ }
25078
+ /**
25079
+ * Draws one tiny projected surface spot by sampling local mesh tangents.
25080
+ *
25081
+ * @private helper of `octopus3d3AvatarVisual`
25082
+ */
25083
+ function drawProjectedSurfaceSpot(options) {
25084
+ const { context, surfaceOptions, center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, latitude, longitude, radiusScale, } = options;
25085
+ const localCenter = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude);
25086
+ const localHorizontal = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude + 0.018);
25087
+ const localVertical = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude + 0.018, longitude);
25088
+ const sceneCenterPoint = transformScenePoint(localCenter, center, rotationX, rotationY);
25089
+ if (sceneCenterPoint.z <= center.z - size * 0.012) {
25090
+ return;
25091
+ }
25092
+ const projectedCenterPoint = projectScenePoint(sceneCenterPoint, size, sceneCenterX, sceneCenterY);
25093
+ const projectedHorizontalPoint = projectScenePoint(transformScenePoint(localHorizontal, center, rotationX, rotationY), size, sceneCenterX, sceneCenterY);
25094
+ const projectedVerticalPoint = projectScenePoint(transformScenePoint(localVertical, center, rotationX, rotationY), size, sceneCenterX, sceneCenterY);
25095
+ const horizontalRadius = clampNumber$1(Math.hypot(projectedHorizontalPoint.x - projectedCenterPoint.x, projectedHorizontalPoint.y - projectedCenterPoint.y) *
25096
+ radiusScale *
25097
+ 0.74, size * 0.003, size * 0.018);
25098
+ const verticalRadius = clampNumber$1(Math.hypot(projectedVerticalPoint.x - projectedCenterPoint.x, projectedVerticalPoint.y - projectedCenterPoint.y) *
25099
+ radiusScale *
25100
+ 0.52, size * 0.0024, size * 0.014);
25101
+ const rotation = Math.atan2(projectedHorizontalPoint.y - projectedCenterPoint.y, projectedHorizontalPoint.x - projectedCenterPoint.x);
25102
+ context.save();
25103
+ context.translate(projectedCenterPoint.x, projectedCenterPoint.y);
25104
+ context.rotate(rotation);
25105
+ context.beginPath();
25106
+ context.ellipse(0, 0, horizontalRadius, verticalRadius, 0, 0, Math.PI * 2);
25107
+ context.fillStyle = `${palette.highlight}73`;
25108
+ context.fill();
25109
+ context.strokeStyle = `${palette.highlight}99`;
25110
+ context.lineWidth = Math.max(0.7, size * 0.0028);
25111
+ context.stroke();
25112
+ context.restore();
25113
+ }
25114
+ /**
25115
+ * Resolves a signed angular distance from the source longitude to the target longitude.
25116
+ *
25117
+ * @private helper of `octopus3d3AvatarVisual`
25118
+ */
25119
+ function resolveSignedAngularDistance(sourceLongitude, targetLongitude) {
25120
+ return Math.atan2(Math.sin(targetLongitude - sourceLongitude), Math.cos(targetLongitude - sourceLongitude));
25121
+ }
25122
+ /**
25123
+ * Smoothly maps a value between two bounds into `[0, 1]`.
25124
+ *
25125
+ * @private helper of `octopus3d3AvatarVisual`
25126
+ */
25127
+ function smoothStep(edgeStart, edgeEnd, value) {
25128
+ const progress = clampNumber$1((value - edgeStart) / (edgeEnd - edgeStart), 0, 1);
25129
+ return progress * progress * (3 - 2 * progress);
25130
+ }
25131
+
24624
25132
  /* eslint-disable no-magic-numbers */
24625
25133
  /**
24626
25134
  * Octopus avatar visual.
@@ -25391,6 +25899,7 @@ const AVATAR_VISUALS = [
25391
25899
  octopus3AvatarVisual,
25392
25900
  octopus3dAvatarVisual,
25393
25901
  octopus3d2AvatarVisual,
25902
+ octopus3d3AvatarVisual,
25394
25903
  asciiOctopusAvatarVisual,
25395
25904
  minecraftAvatarVisual,
25396
25905
  minecraft2AvatarVisual,