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