@promptbook/remote-server 0.112.0-103 → 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.
package/esm/index.es.js CHANGED
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
40
40
  * @generated
41
41
  * @see https://github.com/webgptorg/promptbook
42
42
  */
43
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-103';
43
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-104';
44
44
  /**
45
45
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
46
46
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -14716,7 +14716,7 @@ function fillTextureRect(texture, x, y, width, height, color) {
14716
14716
  *
14717
14717
  * @private helper of `minecraft2AvatarVisual`
14718
14718
  */
14719
- const LIGHT_DIRECTION$2 = normalizeVector3({
14719
+ const LIGHT_DIRECTION$3 = normalizeVector3({
14720
14720
  x: 0.4,
14721
14721
  y: -0.65,
14722
14722
  z: 0.92,
@@ -14928,7 +14928,7 @@ function resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY) {
14928
14928
  corners: projectedCorners,
14929
14929
  texture: faceDefinition.texture,
14930
14930
  averageDepth: transformedCorners.reduce((depthSum, corner) => depthSum + corner.z, 0) / transformedCorners.length,
14931
- lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION$2), -1, 1),
14931
+ lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION$3), -1, 1),
14932
14932
  outlineColor: cuboid.outlineColor,
14933
14933
  };
14934
14934
  });
@@ -16119,7 +16119,7 @@ function formatAlphaHex(opacity) {
16119
16119
  *
16120
16120
  * @private helper of `octopus3dAvatarVisual`
16121
16121
  */
16122
- const LIGHT_DIRECTION$1 = normalizeVector3({
16122
+ const LIGHT_DIRECTION$2 = normalizeVector3({
16123
16123
  x: 0.48,
16124
16124
  y: -0.62,
16125
16125
  z: 0.94,
@@ -16329,7 +16329,7 @@ function resolveVisibleEllipsoidPatches(options) {
16329
16329
  corners: projectedCorners,
16330
16330
  averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
16331
16331
  transformedCorners.length,
16332
- lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
16332
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$2), -1, 1),
16333
16333
  fillStyle: resolveSurfacePatchFillStyle(palette, verticalProgress + verticalColorBias),
16334
16334
  outlineColor,
16335
16335
  });
@@ -16518,7 +16518,7 @@ function resolveEllipsoidSurfaceDepth(radiusX, radiusY, radiusZ, x, y) {
16518
16518
  *
16519
16519
  * @private helper of `octopus3d2AvatarVisual`
16520
16520
  */
16521
- const LIGHT_DIRECTION = normalizeVector3({
16521
+ const LIGHT_DIRECTION$1 = normalizeVector3({
16522
16522
  x: 0.38,
16523
16523
  y: -0.6,
16524
16524
  z: 0.98,
@@ -16667,7 +16667,7 @@ function resolveVisibleBlobbyOctopusPatches(options) {
16667
16667
  corners: projectedCorners,
16668
16668
  averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
16669
16669
  transformedCorners.length,
16670
- lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
16670
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
16671
16671
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
16672
16672
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
16673
16673
  });
@@ -16767,6 +16767,516 @@ function drawBlobbySurfacePatch(context, surfacePatch) {
16767
16767
  context.restore();
16768
16768
  }
16769
16769
 
16770
+ /* eslint-disable no-magic-numbers */
16771
+ /**
16772
+ * Light direction used by the continuous octopus mesh shading.
16773
+ *
16774
+ * @private helper of `octopus3d3AvatarVisual`
16775
+ */
16776
+ const LIGHT_DIRECTION = normalizeVector3({
16777
+ x: 0.34,
16778
+ y: -0.62,
16779
+ z: 1,
16780
+ });
16781
+ /**
16782
+ * Real-octopus tentacle count used by the continuous lower mesh.
16783
+ *
16784
+ * @private helper of `octopus3d3AvatarVisual`
16785
+ */
16786
+ const OCTOPUS_TENTACLE_COUNT = 8;
16787
+ /**
16788
+ * Octopus 3D 3 avatar visual.
16789
+ *
16790
+ * @private built-in avatar visual
16791
+ */
16792
+ const octopus3d3AvatarVisual = {
16793
+ id: 'octopus3d3',
16794
+ title: 'Octopus 3D 3',
16795
+ description: 'Cute continuous 3D octopus with a blobby single mesh, waving tentacle lobes, rich shading, and cursor-aware eyes.',
16796
+ isAnimated: true,
16797
+ supportsPointerTracking: true,
16798
+ render({ context, size, palette, createRandom, timeMs, interaction }) {
16799
+ const morphologyProfile = createOctopus3MorphologyProfile(createRandom);
16800
+ const animationRandom = createRandom('octopus3d3-animation-profile');
16801
+ const eyeRandom = createRandom('octopus3d3-eye-profile');
16802
+ const animationPhase = animationRandom() * Math.PI * 2;
16803
+ const tentacleProfiles = createContinuousTentacleProfiles(createRandom, morphologyProfile);
16804
+ const sceneCenterX = size * 0.5;
16805
+ const sceneCenterY = size * 0.535;
16806
+ const bob = Math.sin(timeMs / 960 + animationPhase) * size * 0.012;
16807
+ const meshCenter = {
16808
+ x: interaction.bodyOffsetX * size * 0.048 + size * morphologyProfile.body.centerXJitterRatio * 0.44,
16809
+ y: -size * 0.07 + interaction.bodyOffsetY * size * 0.026 + bob,
16810
+ z: interaction.intensity * size * 0.018,
16811
+ };
16812
+ const rotationY = -0.1 +
16813
+ Math.sin(timeMs / 2700 + animationPhase) * 0.035 +
16814
+ interaction.bodyOffsetX * 0.22 +
16815
+ interaction.gazeX * 0.88;
16816
+ const rotationX = -0.07 +
16817
+ Math.cos(timeMs / 3100 + animationPhase * 0.7) * 0.018 -
16818
+ interaction.bodyOffsetY * 0.08 -
16819
+ interaction.gazeY * 0.38;
16820
+ const surfaceOptions = {
16821
+ radiusX: size * morphologyProfile.body.bodyRadiusRatio * morphologyProfile.body.horizontalStretch * 1.1,
16822
+ radiusY: size * morphologyProfile.body.bodyRadiusRatio * morphologyProfile.body.verticalStretch * 1.08,
16823
+ radiusZ: size *
16824
+ morphologyProfile.body.bodyRadiusRatio *
16825
+ (1.02 + (morphologyProfile.body.horizontalStretch - 1) * 0.18),
16826
+ morphologyProfile,
16827
+ timeMs,
16828
+ animationPhase,
16829
+ tentacleProfiles,
16830
+ };
16831
+ const surfacePatches = resolveVisibleContinuousOctopusPatches({
16832
+ ...surfaceOptions,
16833
+ center: meshCenter,
16834
+ rotationX,
16835
+ rotationY,
16836
+ sceneCenterX,
16837
+ sceneCenterY,
16838
+ size,
16839
+ palette,
16840
+ });
16841
+ const eyeLatitude = clampNumber$1(morphologyProfile.face.eyeCenterYOffsetRatio * 4.2 - 0.03, -0.22, 0.08);
16842
+ const eyeLongitude = clampNumber$1(morphologyProfile.face.eyeSpacingRatio * 3.1, 0.18, 0.32);
16843
+ const mouthLatitude = clampNumber$1(eyeLatitude + 0.2 + morphologyProfile.face.mouthYOffsetRatio, 0.08, 0.34);
16844
+ const mouthCenterLongitude = clampNumber$1(morphologyProfile.face.mouthCenterOffsetRatio * 5.6, -0.08, 0.08);
16845
+ const mouthHalfLongitude = clampNumber$1(eyeLongitude * 0.78, 0.15, 0.28);
16846
+ const mouthCurveLatitude = clampNumber$1(mouthLatitude + morphologyProfile.face.mouthCurveDepthRatio * 0.78, mouthLatitude + 0.03, 0.42);
16847
+ const eyeRadiusX = size * morphologyProfile.face.eyeRadiusXRatio * 0.76;
16848
+ const eyeRadiusY = eyeRadiusX * morphologyProfile.face.eyeHeightRatio * 0.9;
16849
+ drawAvatarFrame(context, size, palette);
16850
+ drawContinuousOctopusAtmosphere(context, size, palette, sceneCenterX, sceneCenterY, interaction, timeMs);
16851
+ drawContinuousOctopusShadow(context, size, palette, interaction, timeMs, morphologyProfile);
16852
+ for (const surfacePatch of surfacePatches.sort((firstSurfacePatch, secondSurfacePatch) => firstSurfacePatch.averageDepth - secondSurfacePatch.averageDepth)) {
16853
+ drawContinuousSurfacePatch(context, surfacePatch);
16854
+ }
16855
+ drawProjectedSurfaceCurrents({
16856
+ context,
16857
+ surfaceOptions,
16858
+ center: meshCenter,
16859
+ rotationX,
16860
+ rotationY,
16861
+ sceneCenterX,
16862
+ sceneCenterY,
16863
+ size,
16864
+ palette,
16865
+ morphologyProfile,
16866
+ timeMs,
16867
+ animationPhase,
16868
+ });
16869
+ drawProjectedTentacleSuckers({
16870
+ context,
16871
+ surfaceOptions,
16872
+ center: meshCenter,
16873
+ rotationX,
16874
+ rotationY,
16875
+ sceneCenterX,
16876
+ sceneCenterY,
16877
+ size,
16878
+ palette,
16879
+ });
16880
+ drawProjectedOrganicEye(context, sampleContinuousOctopusSurfacePoint(surfaceOptions, eyeLatitude, -eyeLongitude), eyeRadiusX, eyeRadiusY, meshCenter, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, timeMs, animationPhase + eyeRandom() * 0.7, interaction, morphologyProfile.face.eyeStyle);
16881
+ 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);
16882
+ drawProjectedOrganicMouth(context, [
16883
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthLatitude, mouthCenterLongitude - mouthHalfLongitude),
16884
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthCurveLatitude, mouthCenterLongitude),
16885
+ sampleContinuousOctopusSurfacePoint(surfaceOptions, mouthLatitude, mouthCenterLongitude + mouthHalfLongitude),
16886
+ ], meshCenter, rotationX, rotationY, sceneCenterX, sceneCenterY, palette, size);
16887
+ },
16888
+ };
16889
+ /**
16890
+ * Creates seeded tentacle-lobe profiles around the visible lower octopus body.
16891
+ *
16892
+ * @private helper of `octopus3d3AvatarVisual`
16893
+ */
16894
+ function createContinuousTentacleProfiles(createRandom, morphologyProfile) {
16895
+ return Array.from({ length: OCTOPUS_TENTACLE_COUNT }, (_, tentacleIndex) => {
16896
+ const tentacleRandom = createRandom(`octopus3d3-tentacle-${tentacleIndex}`);
16897
+ const progress = tentacleIndex / (OCTOPUS_TENTACLE_COUNT - 1);
16898
+ return {
16899
+ centerLongitude: -Math.PI * 0.86 +
16900
+ progress * Math.PI * 1.72 +
16901
+ (tentacleRandom() - 0.5) * (0.08 + morphologyProfile.tentacles.rootSpreadScale * 0.03),
16902
+ widthScale: 0.86 + tentacleRandom() * 0.34 + (morphologyProfile.tentacles.baseWidthScale - 1) * 0.16,
16903
+ lengthScale: 0.86 + tentacleRandom() * 0.36 + (morphologyProfile.tentacles.flowLengthScale - 1) * 0.22,
16904
+ swayScale: 0.82 + tentacleRandom() * 0.38 + (morphologyProfile.tentacles.swayScale - 1) * 0.2,
16905
+ depthScale: 0.86 + tentacleRandom() * 0.32 + (morphologyProfile.tentacles.tipReachScale - 1) * 0.2,
16906
+ phase: tentacleRandom() * Math.PI * 2,
16907
+ suckerSide: tentacleRandom() > 0.5 ? 1 : -1,
16908
+ };
16909
+ });
16910
+ }
16911
+ /**
16912
+ * Draws the soft underwater atmosphere behind the continuous octopus mesh.
16913
+ *
16914
+ * @private helper of `octopus3d3AvatarVisual`
16915
+ */
16916
+ function drawContinuousOctopusAtmosphere(context, size, palette, sceneCenterX, sceneCenterY, interaction, timeMs) {
16917
+ 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));
16918
+ glowGradient.addColorStop(0, `${palette.highlight}66`);
16919
+ glowGradient.addColorStop(0.34, `${palette.accent}2e`);
16920
+ glowGradient.addColorStop(1, `${palette.highlight}00`);
16921
+ context.fillStyle = glowGradient;
16922
+ context.fillRect(0, 0, size, size);
16923
+ 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);
16924
+ lowerGradient.addColorStop(0, `${palette.secondary}25`);
16925
+ lowerGradient.addColorStop(1, `${palette.secondary}00`);
16926
+ context.fillStyle = lowerGradient;
16927
+ context.fillRect(0, 0, size, size);
16928
+ }
16929
+ /**
16930
+ * Draws the soft lower shadow that anchors the octopus in the avatar frame.
16931
+ *
16932
+ * @private helper of `octopus3d3AvatarVisual`
16933
+ */
16934
+ function drawContinuousOctopusShadow(context, size, palette, interaction, timeMs, morphologyProfile) {
16935
+ context.save();
16936
+ context.fillStyle = `${palette.shadow}66`;
16937
+ context.filter = `blur(${size * 0.025}px)`;
16938
+ context.beginPath();
16939
+ 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);
16940
+ context.fill();
16941
+ context.restore();
16942
+ }
16943
+ /**
16944
+ * Resolves visible projected patches for the continuous octopus mesh.
16945
+ *
16946
+ * @private helper of `octopus3d3AvatarVisual`
16947
+ */
16948
+ function resolveVisibleContinuousOctopusPatches(options) {
16949
+ const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
16950
+ const latitudePatchCount = 16;
16951
+ const longitudePatchCount = 40;
16952
+ const surfacePatches = [];
16953
+ for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
16954
+ const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
16955
+ const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
16956
+ const centerLatitude = (startLatitude + endLatitude) / 2;
16957
+ const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
16958
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
16959
+ const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
16960
+ const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
16961
+ const centerLongitude = (startLongitude + endLongitude) / 2;
16962
+ const localCorners = [
16963
+ sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
16964
+ sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
16965
+ sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
16966
+ sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
16967
+ ];
16968
+ const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
16969
+ const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
16970
+ if (surfaceNormal.z <= 0.008) {
16971
+ continue;
16972
+ }
16973
+ const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
16974
+ const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
16975
+ const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
16976
+ surfacePatches.push({
16977
+ corners: projectedCorners,
16978
+ averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
16979
+ transformedCorners.length,
16980
+ lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
16981
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
16982
+ outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
16983
+ });
16984
+ }
16985
+ }
16986
+ return surfacePatches;
16987
+ }
16988
+ /**
16989
+ * Samples one point on the continuous Octopus 3D 3 surface.
16990
+ *
16991
+ * The lower hemisphere is pulled into eight seeded waving lobes, so the portrait reads as
16992
+ * tentacled while still being rendered as one connected blobby mesh.
16993
+ *
16994
+ * @private helper of `octopus3d3AvatarVisual`
16995
+ */
16996
+ function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
16997
+ const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
16998
+ const cosineLatitude = Math.max(0, Math.cos(latitude));
16999
+ const verticalProgress = (Math.sin(latitude) + 1) / 2;
17000
+ const upperBlend = Math.pow(1 - verticalProgress, 1.28);
17001
+ const lowerBlend = smoothStep(0.38, 1, verticalProgress);
17002
+ const tipBlend = smoothStep(0.68, 1, verticalProgress);
17003
+ const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
17004
+ const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
17005
+ const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
17006
+ const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
17007
+ const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
17008
+ animationPhase * 0.6 +
17009
+ timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
17010
+ (0.018 + morphologyProfile.body.wobbleAmplitudeRatio * 0.8) *
17011
+ (0.3 + lowerBlend * 0.7);
17012
+ const tentacleWave = Math.sin(timeMs / 760 + tentacleInfluence.phase + verticalProgress * 2.4) *
17013
+ lowerBlend *
17014
+ tentacleInfluence.core *
17015
+ tentacleInfluence.swayScale;
17016
+ const horizontalScale = 1.04 +
17017
+ mantleRipple +
17018
+ lowerBlend * (0.16 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.1) +
17019
+ lowerBlend * tentacleInfluence.core * (0.2 + lowerLobeWave * 0.12) -
17020
+ upperBlend * 0.08;
17021
+ const depthScale = 1.06 +
17022
+ upperBlend * 0.16 +
17023
+ Math.max(0, Math.cos(effectiveLongitude)) * 0.1 +
17024
+ lowerBlend * tentacleInfluence.core * (0.1 + tentacleInfluence.depthScale * 0.06) -
17025
+ Math.max(0, -Math.cos(effectiveLongitude)) * 0.05;
17026
+ const tentacleTubeRadius = lowerBlend *
17027
+ tentacleInfluence.core *
17028
+ (0.11 + tipBlend * 0.06 + tentacleInfluence.widthScale * 0.025) *
17029
+ radiusX;
17030
+ const planarRadiusX = cosineLatitude * radiusX * horizontalScale + tentacleTubeRadius;
17031
+ const planarRadiusZ = cosineLatitude * radiusZ * depthScale + tentacleTubeRadius * 0.72;
17032
+ const lowerDrop = lowerBlend *
17033
+ radiusY *
17034
+ (0.18 +
17035
+ tentacleInfluence.core *
17036
+ (0.38 +
17037
+ tentacleInfluence.lengthScale * 0.22 +
17038
+ (morphologyProfile.tentacles.flowLengthScale - 1) * 0.08));
17039
+ return {
17040
+ x: Math.sin(effectiveLongitude) * planarRadiusX +
17041
+ tentacleWave * radiusX * (0.052 + tipBlend * 0.05),
17042
+ y: Math.sin(latitude) * radiusY * (1 + upperBlend * 0.12) -
17043
+ upperBlend * radiusY * 0.1 +
17044
+ lowerDrop +
17045
+ Math.sin(timeMs / 1420 + animationPhase + latitude * 1.6) * lowerBlend * radiusY * 0.018 +
17046
+ Math.cos(timeMs / 880 + tentacleInfluence.phase) *
17047
+ lowerBlend *
17048
+ tipBlend *
17049
+ tentacleInfluence.core *
17050
+ radiusY *
17051
+ 0.034,
17052
+ z: Math.cos(effectiveLongitude) * planarRadiusZ +
17053
+ Math.cos(timeMs / 980 + tentacleInfluence.phase + verticalProgress) *
17054
+ lowerBlend *
17055
+ tentacleInfluence.core *
17056
+ radiusZ *
17057
+ 0.04,
17058
+ };
17059
+ }
17060
+ /**
17061
+ * Blends nearby seeded tentacle profiles at one mesh longitude.
17062
+ *
17063
+ * @private helper of `octopus3d3AvatarVisual`
17064
+ */
17065
+ function resolveContinuousTentacleInfluence(options, longitude) {
17066
+ let totalWeight = 0;
17067
+ let weightedSin = 0;
17068
+ let weightedCos = 0;
17069
+ let weightedWidthScale = 0;
17070
+ let weightedLengthScale = 0;
17071
+ let weightedSwayScale = 0;
17072
+ let weightedDepthScale = 0;
17073
+ let weightedPhase = 0;
17074
+ for (const tentacleProfile of options.tentacleProfiles) {
17075
+ const distance = Math.abs(resolveSignedAngularDistance(longitude, tentacleProfile.centerLongitude));
17076
+ const width = 0.2 * tentacleProfile.widthScale;
17077
+ const weight = Math.exp(-(distance * distance) / (width * width));
17078
+ totalWeight += weight;
17079
+ weightedSin += Math.sin(tentacleProfile.centerLongitude) * weight;
17080
+ weightedCos += Math.cos(tentacleProfile.centerLongitude) * weight;
17081
+ weightedWidthScale += tentacleProfile.widthScale * weight;
17082
+ weightedLengthScale += tentacleProfile.lengthScale * weight;
17083
+ weightedSwayScale += tentacleProfile.swayScale * weight;
17084
+ weightedDepthScale += tentacleProfile.depthScale * weight;
17085
+ weightedPhase += tentacleProfile.phase * weight;
17086
+ }
17087
+ if (totalWeight < 0.0001) {
17088
+ return {
17089
+ core: 0,
17090
+ centerLongitude: longitude,
17091
+ widthScale: 1,
17092
+ lengthScale: 1,
17093
+ swayScale: 1,
17094
+ depthScale: 1,
17095
+ phase: 0,
17096
+ };
17097
+ }
17098
+ return {
17099
+ core: clampNumber$1(totalWeight, 0, 1),
17100
+ centerLongitude: Math.atan2(weightedSin / totalWeight, weightedCos / totalWeight),
17101
+ widthScale: weightedWidthScale / totalWeight,
17102
+ lengthScale: weightedLengthScale / totalWeight,
17103
+ swayScale: weightedSwayScale / totalWeight,
17104
+ depthScale: weightedDepthScale / totalWeight,
17105
+ phase: weightedPhase / totalWeight,
17106
+ };
17107
+ }
17108
+ /**
17109
+ * Resolves the soft lower wave that makes the continuous mesh read as a set of tentacles.
17110
+ *
17111
+ * @private helper of `octopus3d3AvatarVisual`
17112
+ */
17113
+ function resolveContinuousLobeWave(options, longitude) {
17114
+ const { morphologyProfile, animationPhase, timeMs } = options;
17115
+ return (Math.cos(longitude * OCTOPUS_TENTACLE_COUNT + animationPhase + timeMs / (980 + morphologyProfile.body.lobeCount * 18)) +
17116
+ 1) / 2;
17117
+ }
17118
+ /**
17119
+ * Resolves one base fill tone for a patch on the continuous octopus mesh.
17120
+ *
17121
+ * @private helper of `octopus3d3AvatarVisual`
17122
+ */
17123
+ function resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, forwardness, tentacleCore, lowerLobeWave) {
17124
+ const tonalProgress = clampNumber$1(verticalProgress + lowerLobeWave * 0.1 + tentacleCore * 0.08 - forwardness * 0.08, 0, 1);
17125
+ if (tonalProgress < 0.14) {
17126
+ return palette.highlight;
17127
+ }
17128
+ if (tonalProgress < 0.32) {
17129
+ return palette.secondary;
17130
+ }
17131
+ if (tonalProgress < 0.72) {
17132
+ return forwardness > 0.55 ? palette.secondary : palette.primary;
17133
+ }
17134
+ return tentacleCore > 0.44 ? `${palette.primary}f4` : `${palette.shadow}ee`;
17135
+ }
17136
+ /**
17137
+ * Draws one projected mesh patch with soft shading and a subtle edge.
17138
+ *
17139
+ * @private helper of `octopus3d3AvatarVisual`
17140
+ */
17141
+ function drawContinuousSurfacePatch(context, surfacePatch) {
17142
+ drawProjectedQuad(context, surfacePatch.corners, surfacePatch.fillStyle);
17143
+ if (surfacePatch.lightIntensity > 0) {
17144
+ drawProjectedQuad(context, surfacePatch.corners, `rgba(255, 255, 255, ${0.18 * surfacePatch.lightIntensity})`);
17145
+ }
17146
+ else if (surfacePatch.lightIntensity < 0) {
17147
+ drawProjectedQuad(context, surfacePatch.corners, `rgba(0, 0, 0, ${0.25 * Math.abs(surfacePatch.lightIntensity)})`);
17148
+ }
17149
+ context.save();
17150
+ context.beginPath();
17151
+ context.moveTo(surfacePatch.corners[0].x, surfacePatch.corners[0].y);
17152
+ for (let cornerIndex = 1; cornerIndex < surfacePatch.corners.length; cornerIndex++) {
17153
+ context.lineTo(surfacePatch.corners[cornerIndex].x, surfacePatch.corners[cornerIndex].y);
17154
+ }
17155
+ context.closePath();
17156
+ context.strokeStyle = surfacePatch.outlineColor;
17157
+ context.lineWidth = Math.max(0.7, getProjectedQuadPerimeter(surfacePatch.corners) * 0.0032);
17158
+ context.lineJoin = 'round';
17159
+ context.stroke();
17160
+ context.restore();
17161
+ }
17162
+ /**
17163
+ * Draws projected mantle-current lines on the front of the mesh.
17164
+ *
17165
+ * @private helper of `octopus3d3AvatarVisual`
17166
+ */
17167
+ function drawProjectedSurfaceCurrents(options) {
17168
+ const { context, surfaceOptions, center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, timeMs, animationPhase, } = options;
17169
+ const currentCount = Math.min(6, morphologyProfile.details.mantleCurrentCount);
17170
+ const centerIndex = (currentCount - 1) / 2;
17171
+ context.save();
17172
+ context.lineCap = 'round';
17173
+ context.lineJoin = 'round';
17174
+ for (let currentIndex = 0; currentIndex < currentCount; currentIndex++) {
17175
+ const baseLongitude = (currentIndex - centerIndex) * 0.15;
17176
+ const projectedPoints = [];
17177
+ for (let sampleIndex = 0; sampleIndex < 8; sampleIndex++) {
17178
+ const progress = sampleIndex / 7;
17179
+ const latitude = -0.46 + progress * 0.74;
17180
+ const longitude = baseLongitude +
17181
+ Math.sin(timeMs / 1160 + animationPhase + currentIndex * 0.7 + progress * 2) * 0.035;
17182
+ const scenePoint = transformScenePoint(sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude), center, rotationX, rotationY);
17183
+ if (scenePoint.z > center.z - size * 0.016) {
17184
+ projectedPoints.push(projectScenePoint(scenePoint, size, sceneCenterX, sceneCenterY));
17185
+ }
17186
+ }
17187
+ if (projectedPoints.length < 3) {
17188
+ continue;
17189
+ }
17190
+ context.beginPath();
17191
+ context.moveTo(projectedPoints[0].x, projectedPoints[0].y);
17192
+ for (const projectedPoint of projectedPoints.slice(1)) {
17193
+ context.lineTo(projectedPoint.x, projectedPoint.y);
17194
+ }
17195
+ context.strokeStyle = currentIndex % 2 === 0 ? `${palette.highlight}3d` : `${palette.accent}33`;
17196
+ context.lineWidth = size * (0.0055 + currentIndex * 0.00045);
17197
+ context.stroke();
17198
+ }
17199
+ context.restore();
17200
+ }
17201
+ /**
17202
+ * Draws small projected sucker highlights on the waving lower mesh lobes.
17203
+ *
17204
+ * @private helper of `octopus3d3AvatarVisual`
17205
+ */
17206
+ function drawProjectedTentacleSuckers(options) {
17207
+ const { surfaceOptions, size } = options;
17208
+ const { timeMs } = surfaceOptions;
17209
+ for (const tentacleProfile of surfaceOptions.tentacleProfiles) {
17210
+ if (Math.cos(tentacleProfile.centerLongitude) < -0.12) {
17211
+ continue;
17212
+ }
17213
+ for (let suckerIndex = 0; suckerIndex < 3; suckerIndex++) {
17214
+ const latitude = 0.52 + suckerIndex * 0.14;
17215
+ const sideOffset = tentacleProfile.suckerSide * (0.035 + suckerIndex * 0.012) * tentacleProfile.widthScale;
17216
+ const waveOffset = Math.sin(timeMs / 900 + tentacleProfile.phase + suckerIndex * 0.8) * 0.018;
17217
+ drawProjectedSurfaceSpot({
17218
+ ...options,
17219
+ latitude,
17220
+ longitude: tentacleProfile.centerLongitude + sideOffset + waveOffset,
17221
+ radiusScale: size * (0.0065 - suckerIndex * 0.0007),
17222
+ });
17223
+ }
17224
+ }
17225
+ }
17226
+ /**
17227
+ * Draws one tiny projected surface spot by sampling local mesh tangents.
17228
+ *
17229
+ * @private helper of `octopus3d3AvatarVisual`
17230
+ */
17231
+ function drawProjectedSurfaceSpot(options) {
17232
+ const { context, surfaceOptions, center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, latitude, longitude, radiusScale, } = options;
17233
+ const localCenter = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude);
17234
+ const localHorizontal = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude, longitude + 0.018);
17235
+ const localVertical = sampleContinuousOctopusSurfacePoint(surfaceOptions, latitude + 0.018, longitude);
17236
+ const sceneCenterPoint = transformScenePoint(localCenter, center, rotationX, rotationY);
17237
+ if (sceneCenterPoint.z <= center.z - size * 0.012) {
17238
+ return;
17239
+ }
17240
+ const projectedCenterPoint = projectScenePoint(sceneCenterPoint, size, sceneCenterX, sceneCenterY);
17241
+ const projectedHorizontalPoint = projectScenePoint(transformScenePoint(localHorizontal, center, rotationX, rotationY), size, sceneCenterX, sceneCenterY);
17242
+ const projectedVerticalPoint = projectScenePoint(transformScenePoint(localVertical, center, rotationX, rotationY), size, sceneCenterX, sceneCenterY);
17243
+ const horizontalRadius = clampNumber$1(Math.hypot(projectedHorizontalPoint.x - projectedCenterPoint.x, projectedHorizontalPoint.y - projectedCenterPoint.y) *
17244
+ radiusScale *
17245
+ 0.74, size * 0.003, size * 0.018);
17246
+ const verticalRadius = clampNumber$1(Math.hypot(projectedVerticalPoint.x - projectedCenterPoint.x, projectedVerticalPoint.y - projectedCenterPoint.y) *
17247
+ radiusScale *
17248
+ 0.52, size * 0.0024, size * 0.014);
17249
+ const rotation = Math.atan2(projectedHorizontalPoint.y - projectedCenterPoint.y, projectedHorizontalPoint.x - projectedCenterPoint.x);
17250
+ context.save();
17251
+ context.translate(projectedCenterPoint.x, projectedCenterPoint.y);
17252
+ context.rotate(rotation);
17253
+ context.beginPath();
17254
+ context.ellipse(0, 0, horizontalRadius, verticalRadius, 0, 0, Math.PI * 2);
17255
+ context.fillStyle = `${palette.highlight}73`;
17256
+ context.fill();
17257
+ context.strokeStyle = `${palette.highlight}99`;
17258
+ context.lineWidth = Math.max(0.7, size * 0.0028);
17259
+ context.stroke();
17260
+ context.restore();
17261
+ }
17262
+ /**
17263
+ * Resolves a signed angular distance from the source longitude to the target longitude.
17264
+ *
17265
+ * @private helper of `octopus3d3AvatarVisual`
17266
+ */
17267
+ function resolveSignedAngularDistance(sourceLongitude, targetLongitude) {
17268
+ return Math.atan2(Math.sin(targetLongitude - sourceLongitude), Math.cos(targetLongitude - sourceLongitude));
17269
+ }
17270
+ /**
17271
+ * Smoothly maps a value between two bounds into `[0, 1]`.
17272
+ *
17273
+ * @private helper of `octopus3d3AvatarVisual`
17274
+ */
17275
+ function smoothStep(edgeStart, edgeEnd, value) {
17276
+ const progress = clampNumber$1((value - edgeStart) / (edgeEnd - edgeStart), 0, 1);
17277
+ return progress * progress * (3 - 2 * progress);
17278
+ }
17279
+
16770
17280
  /* eslint-disable no-magic-numbers */
16771
17281
  /**
16772
17282
  * Octopus avatar visual.
@@ -17537,6 +18047,7 @@ const AVATAR_VISUALS = [
17537
18047
  octopus3AvatarVisual,
17538
18048
  octopus3dAvatarVisual,
17539
18049
  octopus3d2AvatarVisual,
18050
+ octopus3d3AvatarVisual,
17540
18051
  asciiOctopusAvatarVisual,
17541
18052
  minecraftAvatarVisual,
17542
18053
  minecraft2AvatarVisual,