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