@asiyst/sdk 0.1.23 → 0.1.25
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/dist/index.cjs +417 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -10
- package/dist/index.d.ts +29 -10
- package/dist/index.js +417 -116
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -97,7 +97,7 @@ var ALL_ACTION_KINDS = [
|
|
|
97
97
|
// src/core/constants.ts
|
|
98
98
|
function resolveSdkVersion() {
|
|
99
99
|
{
|
|
100
|
-
return "0.1.
|
|
100
|
+
return "0.1.24";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
var SDK_VERSION = resolveSdkVersion();
|
|
@@ -395,18 +395,22 @@ function normalizeProjectConfig(raw) {
|
|
|
395
395
|
return base;
|
|
396
396
|
}
|
|
397
397
|
const rawAvatarRecord = isRecord(raw.avatar) ? raw.avatar : void 0;
|
|
398
|
+
const rawConfigRecord = isRecord(raw.config) ? raw.config : void 0;
|
|
399
|
+
const rawManifestRecord = isRecord(raw.manifest) ? raw.manifest : void 0;
|
|
398
400
|
const avatarId = asString(
|
|
399
|
-
raw.avatarId ?? rawAvatarRecord?.avatarId ?? rawAvatarRecord?.id,
|
|
401
|
+
raw.avatarId ?? rawAvatarRecord?.avatarId ?? rawAvatarRecord?.id ?? rawConfigRecord?.avatarId,
|
|
400
402
|
"",
|
|
401
403
|
128
|
|
402
404
|
) || void 0;
|
|
403
|
-
const assetUrl = typeof raw.assetUrl === "string" ? raw.assetUrl : typeof rawAvatarRecord?.assetUrl === "string" ? rawAvatarRecord.assetUrl : void 0;
|
|
404
|
-
const thumbnailUrl = typeof raw.thumbnailUrl === "string" ? raw.thumbnailUrl : typeof rawAvatarRecord?.thumbnailUrl === "string" ? rawAvatarRecord.thumbnailUrl : rawAvatarRecord?.thumbnailUrl === null ? null : void 0;
|
|
405
|
-
const publishedVersion = typeof raw.publishedVersion === "string" ? raw.publishedVersion : typeof rawAvatarRecord?.version === "string" ? rawAvatarRecord.version : void 0;
|
|
406
|
-
const animations = parseAnimations(
|
|
407
|
-
|
|
405
|
+
const assetUrl = typeof raw.assetUrl === "string" && raw.assetUrl ? raw.assetUrl : typeof rawAvatarRecord?.assetUrl === "string" && rawAvatarRecord.assetUrl ? rawAvatarRecord.assetUrl : typeof rawAvatarRecord?.modelUrl === "string" && rawAvatarRecord.modelUrl ? rawAvatarRecord.modelUrl : typeof rawConfigRecord?.assetUrl === "string" && rawConfigRecord.assetUrl ? rawConfigRecord.assetUrl : typeof rawManifestRecord?.assetUrl === "string" && rawManifestRecord.assetUrl ? rawManifestRecord.assetUrl : typeof rawManifestRecord?.modelUrl === "string" && rawManifestRecord.modelUrl ? rawManifestRecord.modelUrl : void 0;
|
|
406
|
+
const thumbnailUrl = typeof raw.thumbnailUrl === "string" ? raw.thumbnailUrl : typeof rawAvatarRecord?.thumbnailUrl === "string" ? rawAvatarRecord.thumbnailUrl : typeof rawConfigRecord?.thumbnailUrl === "string" ? rawConfigRecord.thumbnailUrl : typeof rawManifestRecord?.thumbnailUrl === "string" ? rawManifestRecord.thumbnailUrl : rawAvatarRecord?.thumbnailUrl === null ? null : void 0;
|
|
407
|
+
const publishedVersion = typeof raw.publishedVersion === "string" ? raw.publishedVersion : typeof rawAvatarRecord?.version === "string" ? rawAvatarRecord.version : typeof rawManifestRecord?.version === "string" ? rawManifestRecord.version : void 0;
|
|
408
|
+
const animations = parseAnimations(
|
|
409
|
+
raw.animations ?? rawAvatarRecord?.animations ?? rawConfigRecord?.animations
|
|
410
|
+
);
|
|
411
|
+
const branding = parseBranding(raw.branding ?? rawAvatarRecord?.branding);
|
|
408
412
|
const avatarName = asString(
|
|
409
|
-
raw.avatarName ?? rawAvatarRecord?.name,
|
|
413
|
+
raw.avatarName ?? rawAvatarRecord?.name ?? rawConfigRecord?.avatarName ?? rawManifestRecord?.name,
|
|
410
414
|
base.avatarName,
|
|
411
415
|
40
|
|
412
416
|
);
|
|
@@ -670,39 +674,58 @@ var CloudClient = class {
|
|
|
670
674
|
const avatarAndKeyParams = `?projectId=${encodeURIComponent(this.projectId)}&publicKey=${encodeURIComponent(this.publicKey)}${this.avatarId ? `&avatarId=${encodeURIComponent(this.avatarId)}` : ""}`;
|
|
671
675
|
const baseUrl = this.getApiBaseUrl();
|
|
672
676
|
const resolveAssetUrls = (raw) => {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
677
|
+
let canonicalBase = "https://asiyst.com";
|
|
678
|
+
try {
|
|
679
|
+
if (baseUrl) {
|
|
680
|
+
const u = new URL(baseUrl);
|
|
681
|
+
canonicalBase = u.origin;
|
|
678
682
|
}
|
|
679
|
-
|
|
680
|
-
|
|
683
|
+
} catch {
|
|
684
|
+
canonicalBase = "https://asiyst.com";
|
|
685
|
+
}
|
|
686
|
+
const toAbsolute = (url) => {
|
|
687
|
+
if (typeof url === "string" && url.startsWith("/")) {
|
|
688
|
+
return new URL(url, canonicalBase).href;
|
|
681
689
|
}
|
|
690
|
+
return url;
|
|
691
|
+
};
|
|
692
|
+
if (raw.avatar && typeof raw.avatar === "object" && !Array.isArray(raw.avatar)) {
|
|
693
|
+
const av = { ...raw.avatar };
|
|
694
|
+
av.assetUrl = toAbsolute(av.assetUrl);
|
|
695
|
+
av.thumbnailUrl = toAbsolute(av.thumbnailUrl);
|
|
696
|
+
av.modelUrl = toAbsolute(av.modelUrl);
|
|
697
|
+
av.manifestUrl = toAbsolute(av.manifestUrl);
|
|
682
698
|
if (Array.isArray(av.animations)) {
|
|
683
699
|
av.animations = av.animations.map((item) => {
|
|
684
700
|
if (item && typeof item === "object") {
|
|
685
701
|
const animObj = item;
|
|
686
|
-
|
|
687
|
-
return { ...animObj, assetUrl: new URL(animObj.assetUrl, canonicalBase).href };
|
|
688
|
-
}
|
|
702
|
+
return { ...animObj, assetUrl: toAbsolute(animObj.assetUrl) };
|
|
689
703
|
}
|
|
690
704
|
return item;
|
|
691
705
|
});
|
|
692
706
|
}
|
|
693
707
|
raw.avatar = av;
|
|
694
708
|
}
|
|
695
|
-
if (typeof raw.
|
|
696
|
-
|
|
709
|
+
if (raw.config && typeof raw.config === "object" && !Array.isArray(raw.config)) {
|
|
710
|
+
const cfg = { ...raw.config };
|
|
711
|
+
cfg.assetUrl = toAbsolute(cfg.assetUrl);
|
|
712
|
+
cfg.thumbnailUrl = toAbsolute(cfg.thumbnailUrl);
|
|
713
|
+
cfg.manifestUrl = toAbsolute(cfg.manifestUrl);
|
|
714
|
+
raw.config = cfg;
|
|
697
715
|
}
|
|
698
|
-
if (typeof raw.
|
|
699
|
-
|
|
716
|
+
if (raw.manifest && typeof raw.manifest === "object" && !Array.isArray(raw.manifest)) {
|
|
717
|
+
const mf = { ...raw.manifest };
|
|
718
|
+
mf.assetUrl = toAbsolute(mf.assetUrl);
|
|
719
|
+
mf.thumbnailUrl = toAbsolute(mf.thumbnailUrl);
|
|
720
|
+
mf.modelUrl = toAbsolute(mf.modelUrl);
|
|
721
|
+
raw.manifest = mf;
|
|
700
722
|
}
|
|
723
|
+
raw.assetUrl = toAbsolute(raw.assetUrl);
|
|
724
|
+
raw.thumbnailUrl = toAbsolute(raw.thumbnailUrl);
|
|
725
|
+
raw.manifestUrl = toAbsolute(raw.manifestUrl);
|
|
701
726
|
if (raw.branding && typeof raw.branding === "object" && !Array.isArray(raw.branding)) {
|
|
702
727
|
const br = { ...raw.branding };
|
|
703
|
-
|
|
704
|
-
br.siteLogoUrl = new URL(br.siteLogoUrl, canonicalBase).href;
|
|
705
|
-
}
|
|
728
|
+
br.siteLogoUrl = toAbsolute(br.siteLogoUrl);
|
|
706
729
|
raw.branding = br;
|
|
707
730
|
}
|
|
708
731
|
return raw;
|
|
@@ -715,8 +738,11 @@ var CloudClient = class {
|
|
|
715
738
|
idempotent: true
|
|
716
739
|
});
|
|
717
740
|
if (response.ok && response.data) {
|
|
718
|
-
const
|
|
719
|
-
|
|
741
|
+
const fullData = response.data && typeof response.data === "object" && !Array.isArray(response.data) ? {
|
|
742
|
+
...response.data,
|
|
743
|
+
...response.data.config && typeof response.data.config === "object" ? response.data.config : {}
|
|
744
|
+
} : {};
|
|
745
|
+
return normalizeProjectConfig(resolveAssetUrls(fullData));
|
|
720
746
|
}
|
|
721
747
|
if (response.status === 404) {
|
|
722
748
|
lastError = new ConfigurationError(`Project ${this.projectId} or avatar configuration not found`);
|
|
@@ -1761,7 +1787,7 @@ var AssetLoader = class {
|
|
|
1761
1787
|
}
|
|
1762
1788
|
this.inFlightController = new AbortController();
|
|
1763
1789
|
const abortSignal = options?.signal ? anySignal([this.inFlightController.signal, options.signal]) : this.inFlightController.signal;
|
|
1764
|
-
const timeoutMs = options?.timeoutMs ??
|
|
1790
|
+
const timeoutMs = options?.timeoutMs ?? 6e4;
|
|
1765
1791
|
const timeoutId = setTimeout(() => {
|
|
1766
1792
|
this.inFlightController?.abort();
|
|
1767
1793
|
}, timeoutMs);
|
|
@@ -2109,6 +2135,8 @@ var FbxRenderer = class {
|
|
|
2109
2135
|
this.camera = null;
|
|
2110
2136
|
this.modelRoot = null;
|
|
2111
2137
|
this.mixer = null;
|
|
2138
|
+
this.allAnimations = [];
|
|
2139
|
+
this.currentAction = null;
|
|
2112
2140
|
this.animFrameId = null;
|
|
2113
2141
|
this.lastTime = 0;
|
|
2114
2142
|
this.facing = "right";
|
|
@@ -2127,35 +2155,53 @@ var FbxRenderer = class {
|
|
|
2127
2155
|
if (!glContext) {
|
|
2128
2156
|
throw new Error("WebGLRenderingContext is not available or supported in this browser environment");
|
|
2129
2157
|
}
|
|
2158
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2159
|
+
const width = options?.width || (isMobile ? 180 : 240);
|
|
2160
|
+
const height = options?.height || (isMobile ? 360 : 460);
|
|
2130
2161
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
2131
|
-
|
|
2132
|
-
this.canvas.
|
|
2133
|
-
this.canvas.
|
|
2162
|
+
this.canvas.width = Math.round(width * dpr);
|
|
2163
|
+
this.canvas.height = Math.round(height * dpr);
|
|
2164
|
+
this.canvas.style.width = `${width}px`;
|
|
2165
|
+
this.canvas.style.height = `${height}px`;
|
|
2134
2166
|
try {
|
|
2135
2167
|
this.renderer = new THREE__namespace.WebGLRenderer({
|
|
2136
2168
|
canvas: this.canvas,
|
|
2137
2169
|
alpha: true,
|
|
2138
2170
|
antialias: true,
|
|
2139
|
-
powerPreference: "
|
|
2171
|
+
powerPreference: "high-performance"
|
|
2140
2172
|
});
|
|
2141
2173
|
this.renderer.setPixelRatio(Math.min(dpr, 2));
|
|
2142
|
-
this.renderer.setSize(
|
|
2174
|
+
this.renderer.setSize(width, height, false);
|
|
2143
2175
|
this.renderer.outputColorSpace = THREE__namespace.SRGBColorSpace;
|
|
2176
|
+
this.renderer.shadowMap.enabled = true;
|
|
2177
|
+
this.renderer.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
|
|
2144
2178
|
} catch (err) {
|
|
2145
2179
|
const msg = err instanceof Error ? err.message : String(err);
|
|
2146
2180
|
throw new Error(`Failed to initialize WebGLRenderer: ${msg}`);
|
|
2147
2181
|
}
|
|
2148
2182
|
this.scene = new THREE__namespace.Scene();
|
|
2149
|
-
this.camera = new THREE__namespace.PerspectiveCamera(
|
|
2150
|
-
this.camera.position.set(0, 0, 3.4);
|
|
2183
|
+
this.camera = new THREE__namespace.PerspectiveCamera(45, width / height, 0.1, 100);
|
|
2151
2184
|
const ambientLight = new THREE__namespace.AmbientLight(16777215, 1.2);
|
|
2152
2185
|
this.scene.add(ambientLight);
|
|
2153
|
-
const keyLight = new THREE__namespace.DirectionalLight(
|
|
2154
|
-
keyLight.position.set(
|
|
2186
|
+
const keyLight = new THREE__namespace.DirectionalLight(16774634, 2);
|
|
2187
|
+
keyLight.position.set(3, 4, 3);
|
|
2188
|
+
keyLight.castShadow = true;
|
|
2189
|
+
keyLight.shadow.mapSize.width = 512;
|
|
2190
|
+
keyLight.shadow.mapSize.height = 512;
|
|
2155
2191
|
this.scene.add(keyLight);
|
|
2156
|
-
const fillLight = new THREE__namespace.DirectionalLight(
|
|
2157
|
-
fillLight.position.set(-
|
|
2192
|
+
const fillLight = new THREE__namespace.DirectionalLight(15459032, 1.2);
|
|
2193
|
+
fillLight.position.set(-3, 2, 2);
|
|
2158
2194
|
this.scene.add(fillLight);
|
|
2195
|
+
const rimLight = new THREE__namespace.DirectionalLight(16771286, 1.5);
|
|
2196
|
+
rimLight.position.set(0, 4, -3);
|
|
2197
|
+
this.scene.add(rimLight);
|
|
2198
|
+
const shadowGeo = new THREE__namespace.PlaneGeometry(3, 3);
|
|
2199
|
+
const shadowMat = new THREE__namespace.ShadowMaterial({ opacity: 0.15 });
|
|
2200
|
+
const shadowPlane = new THREE__namespace.Mesh(shadowGeo, shadowMat);
|
|
2201
|
+
shadowPlane.rotation.x = -Math.PI / 2;
|
|
2202
|
+
shadowPlane.position.y = 0;
|
|
2203
|
+
shadowPlane.receiveShadow = true;
|
|
2204
|
+
this.scene.add(shadowPlane);
|
|
2159
2205
|
let rawObject;
|
|
2160
2206
|
let modelAnimations = [];
|
|
2161
2207
|
if (asset.format === "fbx") {
|
|
@@ -2192,32 +2238,39 @@ var FbxRenderer = class {
|
|
|
2192
2238
|
}
|
|
2193
2239
|
}
|
|
2194
2240
|
const { meshCount, vertexCount: totalVertices } = this.validateGeometry(rawObject);
|
|
2195
|
-
const
|
|
2196
|
-
if (
|
|
2241
|
+
const rawBox = new THREE__namespace.Box3().setFromObject(rawObject);
|
|
2242
|
+
if (rawBox.isEmpty()) {
|
|
2197
2243
|
throw new Error("FBX asset geometry bounding box is empty");
|
|
2198
2244
|
}
|
|
2199
|
-
const
|
|
2200
|
-
|
|
2201
|
-
const
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
rawObject.position.z -= center.z;
|
|
2245
|
+
const rawSize = rawBox.getSize(new THREE__namespace.Vector3());
|
|
2246
|
+
const rawCenter = rawBox.getCenter(new THREE__namespace.Vector3());
|
|
2247
|
+
const rawHeight = rawSize.y > 0 ? rawSize.y : 1.8;
|
|
2248
|
+
rawObject.position.set(-rawCenter.x, -rawBox.min.y, -rawCenter.z);
|
|
2249
|
+
const targetVisualHeight = 1.8;
|
|
2250
|
+
const targetScale = targetVisualHeight / rawHeight;
|
|
2206
2251
|
this.modelRoot = new THREE__namespace.Group();
|
|
2207
2252
|
this.modelRoot.add(rawObject);
|
|
2253
|
+
this.modelRoot.scale.setScalar(targetScale);
|
|
2208
2254
|
this.scene.add(this.modelRoot);
|
|
2209
|
-
const
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2255
|
+
const visualCenterY = targetVisualHeight * 0.52;
|
|
2256
|
+
const fovRadians = this.camera.fov * Math.PI / 180;
|
|
2257
|
+
const fitDist = Math.max(2.4, targetVisualHeight / 2 / Math.tan(fovRadians / 2) * 1.25);
|
|
2258
|
+
this.camera.position.set(0, visualCenterY + 0.1, fitDist);
|
|
2259
|
+
this.camera.lookAt(0, visualCenterY, 0);
|
|
2260
|
+
rawObject.traverse((child) => {
|
|
2261
|
+
const mesh = child;
|
|
2262
|
+
if (mesh.isMesh) {
|
|
2263
|
+
mesh.castShadow = true;
|
|
2264
|
+
mesh.receiveShadow = true;
|
|
2265
|
+
}
|
|
2266
|
+
});
|
|
2267
|
+
this.allAnimations = modelAnimations;
|
|
2215
2268
|
if (modelAnimations.length > 0) {
|
|
2216
2269
|
this.mixer = new THREE__namespace.AnimationMixer(rawObject);
|
|
2217
|
-
const
|
|
2218
|
-
if (
|
|
2219
|
-
|
|
2220
|
-
|
|
2270
|
+
const idleClip = modelAnimations.find((c) => c.name.toLowerCase().includes("idle")) || modelAnimations[0];
|
|
2271
|
+
if (idleClip) {
|
|
2272
|
+
this.currentAction = this.mixer.clipAction(idleClip);
|
|
2273
|
+
this.currentAction.play();
|
|
2221
2274
|
}
|
|
2222
2275
|
}
|
|
2223
2276
|
container.replaceChildren();
|
|
@@ -2232,6 +2285,10 @@ var FbxRenderer = class {
|
|
|
2232
2285
|
this.startLoop();
|
|
2233
2286
|
this.setFacing(this.facing);
|
|
2234
2287
|
this.setPose(this.currentPose);
|
|
2288
|
+
if (typeof window !== "undefined") {
|
|
2289
|
+
this.resizeListener = () => this.handleResize();
|
|
2290
|
+
window.addEventListener("resize", this.resizeListener);
|
|
2291
|
+
}
|
|
2235
2292
|
return {
|
|
2236
2293
|
meshCount,
|
|
2237
2294
|
vertexCount: totalVertices,
|
|
@@ -2247,6 +2304,31 @@ var FbxRenderer = class {
|
|
|
2247
2304
|
setPose(pose) {
|
|
2248
2305
|
this.currentPose = pose;
|
|
2249
2306
|
if (!this.modelRoot) return;
|
|
2307
|
+
if (this.mixer && this.allAnimations.length > 1) {
|
|
2308
|
+
let targetClip;
|
|
2309
|
+
if (pose === "speak") {
|
|
2310
|
+
targetClip = this.allAnimations.find(
|
|
2311
|
+
(c) => c.name.toLowerCase().includes("talk") || c.name.toLowerCase().includes("speak")
|
|
2312
|
+
);
|
|
2313
|
+
} else if (pose === "think") {
|
|
2314
|
+
targetClip = this.allAnimations.find(
|
|
2315
|
+
(c) => c.name.toLowerCase().includes("think")
|
|
2316
|
+
);
|
|
2317
|
+
} else {
|
|
2318
|
+
targetClip = this.allAnimations.find((c) => c.name.toLowerCase().includes("idle")) || this.allAnimations[0];
|
|
2319
|
+
}
|
|
2320
|
+
if (targetClip) {
|
|
2321
|
+
const newAction = this.mixer.clipAction(targetClip);
|
|
2322
|
+
if (newAction !== this.currentAction) {
|
|
2323
|
+
newAction.reset().fadeIn(0.25).play();
|
|
2324
|
+
if (this.currentAction) {
|
|
2325
|
+
this.currentAction.fadeOut(0.25);
|
|
2326
|
+
}
|
|
2327
|
+
this.currentAction = newAction;
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2250
2332
|
switch (pose) {
|
|
2251
2333
|
case "point":
|
|
2252
2334
|
this.modelRoot.rotation.z = -0.15;
|
|
@@ -2256,6 +2338,10 @@ var FbxRenderer = class {
|
|
|
2256
2338
|
this.modelRoot.rotation.z = 0.12;
|
|
2257
2339
|
this.modelRoot.rotation.x = -0.1;
|
|
2258
2340
|
break;
|
|
2341
|
+
case "speak":
|
|
2342
|
+
this.modelRoot.rotation.y = this.facing === "left" ? -0.22 : 0.22;
|
|
2343
|
+
this.modelRoot.rotation.x = 0.04;
|
|
2344
|
+
break;
|
|
2259
2345
|
case "celebrate":
|
|
2260
2346
|
this.modelRoot.rotation.z = 0;
|
|
2261
2347
|
this.modelRoot.rotation.x = -0.15;
|
|
@@ -2264,6 +2350,7 @@ var FbxRenderer = class {
|
|
|
2264
2350
|
default:
|
|
2265
2351
|
this.modelRoot.rotation.z = 0;
|
|
2266
2352
|
this.modelRoot.rotation.x = 0;
|
|
2353
|
+
this.modelRoot.rotation.y = this.facing === "left" ? -0.35 : 0.35;
|
|
2267
2354
|
break;
|
|
2268
2355
|
}
|
|
2269
2356
|
}
|
|
@@ -2308,6 +2395,10 @@ var FbxRenderer = class {
|
|
|
2308
2395
|
this.animFrameId = requestAnimationFrame(tick);
|
|
2309
2396
|
}
|
|
2310
2397
|
destroy() {
|
|
2398
|
+
if (typeof window !== "undefined" && this.resizeListener) {
|
|
2399
|
+
window.removeEventListener("resize", this.resizeListener);
|
|
2400
|
+
this.resizeListener = void 0;
|
|
2401
|
+
}
|
|
2311
2402
|
if (this.animFrameId !== null && typeof cancelAnimationFrame !== "undefined") {
|
|
2312
2403
|
cancelAnimationFrame(this.animFrameId);
|
|
2313
2404
|
this.animFrameId = null;
|
|
@@ -2353,6 +2444,30 @@ var FbxRenderer = class {
|
|
|
2353
2444
|
this.modelRoot = null;
|
|
2354
2445
|
this.initialRenderCompleted = false;
|
|
2355
2446
|
}
|
|
2447
|
+
handleResize() {
|
|
2448
|
+
if (!this.canvas || !this.renderer || !this.camera) return;
|
|
2449
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2450
|
+
const width = isMobile ? 180 : 240;
|
|
2451
|
+
const height = isMobile ? 360 : 460;
|
|
2452
|
+
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
2453
|
+
this.canvas.width = Math.round(width * dpr);
|
|
2454
|
+
this.canvas.height = Math.round(height * dpr);
|
|
2455
|
+
this.canvas.style.width = `${width}px`;
|
|
2456
|
+
this.canvas.style.height = `${height}px`;
|
|
2457
|
+
this.camera.aspect = width / height;
|
|
2458
|
+
this.camera.updateProjectionMatrix();
|
|
2459
|
+
this.renderer.setPixelRatio(Math.min(dpr, 2));
|
|
2460
|
+
this.renderer.setSize(width, height, false);
|
|
2461
|
+
}
|
|
2462
|
+
getCamera() {
|
|
2463
|
+
return this.camera;
|
|
2464
|
+
}
|
|
2465
|
+
getModelRoot() {
|
|
2466
|
+
return this.modelRoot;
|
|
2467
|
+
}
|
|
2468
|
+
getMixer() {
|
|
2469
|
+
return this.mixer;
|
|
2470
|
+
}
|
|
2356
2471
|
};
|
|
2357
2472
|
|
|
2358
2473
|
// src/avatar/CssAvatarRenderer.ts
|
|
@@ -2363,7 +2478,7 @@ var AVATAR_CSS = `
|
|
|
2363
2478
|
display: flex;
|
|
2364
2479
|
flex-direction: column;
|
|
2365
2480
|
align-items: center;
|
|
2366
|
-
gap:
|
|
2481
|
+
gap: 4px;
|
|
2367
2482
|
pointer-events: auto;
|
|
2368
2483
|
user-select: none;
|
|
2369
2484
|
}
|
|
@@ -2384,28 +2499,38 @@ var AVATAR_CSS = `
|
|
|
2384
2499
|
padding: 0;
|
|
2385
2500
|
outline: none;
|
|
2386
2501
|
background: #2563eb;
|
|
2502
|
+
transition: width 0.3s ease, height 0.3s ease, background 0.3s ease;
|
|
2503
|
+
}
|
|
2504
|
+
.asiyst-figure.asiyst-3d-active {
|
|
2505
|
+
width: 240px !important;
|
|
2506
|
+
height: 460px !important;
|
|
2507
|
+
background: transparent !important;
|
|
2508
|
+
border-radius: 0 !important;
|
|
2509
|
+
box-shadow: none !important;
|
|
2510
|
+
overflow: visible !important;
|
|
2511
|
+
}
|
|
2512
|
+
@media (max-width: 640px) {
|
|
2513
|
+
.asiyst-figure.asiyst-3d-active {
|
|
2514
|
+
width: 180px !important;
|
|
2515
|
+
height: 360px !important;
|
|
2516
|
+
}
|
|
2387
2517
|
}
|
|
2388
|
-
.asiyst-figure[data-pose="point"] { transform: rotate(-12deg); }
|
|
2389
|
-
.asiyst-figure[data-pose="think"] { opacity: 0.85; }
|
|
2390
|
-
.asiyst-figure[data-pose="celebrate"] { transform: scale(1.08); }
|
|
2391
2518
|
.asiyst-avatar-viewport {
|
|
2392
|
-
position:
|
|
2393
|
-
inset: 0;
|
|
2519
|
+
position: relative;
|
|
2394
2520
|
width: 100%;
|
|
2395
2521
|
height: 100%;
|
|
2396
2522
|
display: grid;
|
|
2397
2523
|
place-items: center;
|
|
2398
2524
|
border-radius: inherit;
|
|
2399
|
-
overflow:
|
|
2400
|
-
pointer-events:
|
|
2525
|
+
overflow: visible;
|
|
2526
|
+
pointer-events: auto;
|
|
2401
2527
|
}
|
|
2402
2528
|
.asiyst-avatar-canvas {
|
|
2403
2529
|
width: 100%;
|
|
2404
2530
|
height: 100%;
|
|
2405
2531
|
object-fit: contain;
|
|
2406
|
-
border-radius: inherit;
|
|
2407
2532
|
display: block;
|
|
2408
|
-
pointer-events:
|
|
2533
|
+
pointer-events: auto;
|
|
2409
2534
|
}
|
|
2410
2535
|
.asiyst-avatar-graphic {
|
|
2411
2536
|
width: 100%;
|
|
@@ -2459,11 +2584,73 @@ var AVATAR_CSS = `
|
|
|
2459
2584
|
padding: 8px 10px;
|
|
2460
2585
|
font: 13px/1.4 system-ui, sans-serif;
|
|
2461
2586
|
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
|
|
2587
|
+
margin-bottom: 4px;
|
|
2588
|
+
}
|
|
2589
|
+
.asiyst-name-tag {
|
|
2590
|
+
display: inline-flex;
|
|
2591
|
+
align-items: center;
|
|
2592
|
+
gap: 6px;
|
|
2593
|
+
background: rgba(255, 255, 255, 0.95);
|
|
2594
|
+
backdrop-filter: blur(8px);
|
|
2595
|
+
border: 1px solid rgba(226, 232, 240, 0.9);
|
|
2596
|
+
border-radius: 9999px;
|
|
2597
|
+
padding: 4px 12px;
|
|
2598
|
+
font-size: 11px;
|
|
2599
|
+
font-weight: 700;
|
|
2600
|
+
color: #1e293b;
|
|
2601
|
+
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
|
|
2602
|
+
user-select: none;
|
|
2603
|
+
margin-bottom: 2px;
|
|
2604
|
+
pointer-events: none;
|
|
2605
|
+
transition: opacity 0.2s ease;
|
|
2606
|
+
}
|
|
2607
|
+
.asiyst-name-sparkle { color: #f59e0b; font-size: 12px; font-weight: 900; }
|
|
2608
|
+
.asiyst-name-dot {
|
|
2609
|
+
width: 6px;
|
|
2610
|
+
height: 6px;
|
|
2611
|
+
border-radius: 50%;
|
|
2612
|
+
background: #10b981;
|
|
2613
|
+
display: inline-block;
|
|
2614
|
+
animation: asiyst-pulse 2s infinite;
|
|
2615
|
+
}
|
|
2616
|
+
.asiyst-name-status {
|
|
2617
|
+
font-size: 10px;
|
|
2618
|
+
color: #64748b;
|
|
2619
|
+
font-weight: 500;
|
|
2620
|
+
text-transform: uppercase;
|
|
2621
|
+
}
|
|
2622
|
+
@keyframes asiyst-pulse {
|
|
2623
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
2624
|
+
50% { opacity: 0.4; transform: scale(1.3); }
|
|
2625
|
+
}
|
|
2626
|
+
.asiyst-open-chat-btn {
|
|
2627
|
+
display: inline-flex;
|
|
2628
|
+
align-items: center;
|
|
2629
|
+
gap: 6px;
|
|
2630
|
+
background: #0f172a;
|
|
2631
|
+
color: #fbbf24;
|
|
2632
|
+
border: 1px solid rgba(245, 158, 11, 0.6);
|
|
2633
|
+
border-radius: 9999px;
|
|
2634
|
+
padding: 6px 14px;
|
|
2635
|
+
font-size: 12px;
|
|
2636
|
+
font-weight: 700;
|
|
2637
|
+
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
|
|
2638
|
+
cursor: pointer;
|
|
2639
|
+
margin-top: 4px;
|
|
2640
|
+
pointer-events: auto;
|
|
2641
|
+
transition: transform 0.15s ease, background-color 0.15s ease;
|
|
2642
|
+
}
|
|
2643
|
+
.asiyst-open-chat-btn:hover {
|
|
2644
|
+
transform: scale(1.05);
|
|
2645
|
+
background: #1e293b;
|
|
2646
|
+
}
|
|
2647
|
+
.asiyst-open-chat-btn svg {
|
|
2648
|
+
stroke: #fbbf24;
|
|
2462
2649
|
}
|
|
2463
|
-
.asiyst-name { font: 600 12px/1 system-ui, sans-serif; color: #0f172a; }
|
|
2464
2650
|
@media (prefers-reduced-motion: reduce) {
|
|
2465
2651
|
.asiyst-avatar.asiyst-animate { transition: none; }
|
|
2466
2652
|
.asiyst-avatar-loader { animation: none; }
|
|
2653
|
+
.asiyst-name-dot { animation: none; }
|
|
2467
2654
|
}
|
|
2468
2655
|
`;
|
|
2469
2656
|
var CssAvatarRenderer = class {
|
|
@@ -2474,6 +2661,7 @@ var CssAvatarRenderer = class {
|
|
|
2474
2661
|
this.pose = "idle";
|
|
2475
2662
|
this.accentColor = "#2563eb";
|
|
2476
2663
|
this.avatarName = "Asiyst";
|
|
2664
|
+
this.isPanelOpen = false;
|
|
2477
2665
|
// Asset loading & rendering state
|
|
2478
2666
|
this.assetLoader = new AssetLoader();
|
|
2479
2667
|
this.fbxRenderer = null;
|
|
@@ -2489,6 +2677,20 @@ var CssAvatarRenderer = class {
|
|
|
2489
2677
|
this.root = doc.createElement("div");
|
|
2490
2678
|
this.root.className = "asiyst-avatar asiyst-animate";
|
|
2491
2679
|
this.root.setAttribute("role", "img");
|
|
2680
|
+
this.nameTagEl = doc.createElement("div");
|
|
2681
|
+
this.nameTagEl.className = "asiyst-name-tag";
|
|
2682
|
+
const sparkle = doc.createElement("span");
|
|
2683
|
+
sparkle.className = "asiyst-name-sparkle";
|
|
2684
|
+
sparkle.textContent = "\u2726";
|
|
2685
|
+
this.nameTextEl = doc.createElement("span");
|
|
2686
|
+
this.nameTextEl.className = "asiyst-name-text";
|
|
2687
|
+
this.nameTextEl.textContent = config.avatarName;
|
|
2688
|
+
const dot = doc.createElement("span");
|
|
2689
|
+
dot.className = "asiyst-name-dot";
|
|
2690
|
+
this.statusTextEl = doc.createElement("span");
|
|
2691
|
+
this.statusTextEl.className = "asiyst-name-status";
|
|
2692
|
+
this.statusTextEl.textContent = "(IDLE)";
|
|
2693
|
+
this.nameTagEl.append(sparkle, this.nameTextEl, dot, this.statusTextEl);
|
|
2492
2694
|
this.figure = doc.createElement("button");
|
|
2493
2695
|
this.figure.type = "button";
|
|
2494
2696
|
this.figure.className = "asiyst-figure";
|
|
@@ -2497,12 +2699,26 @@ var CssAvatarRenderer = class {
|
|
|
2497
2699
|
this.viewport = doc.createElement("div");
|
|
2498
2700
|
this.viewport.className = "asiyst-avatar-viewport";
|
|
2499
2701
|
this.figure.appendChild(this.viewport);
|
|
2500
|
-
this.nameEl = doc.createElement("div");
|
|
2501
|
-
this.nameEl.className = "asiyst-name";
|
|
2502
2702
|
this.bubble = doc.createElement("div");
|
|
2503
2703
|
this.bubble.className = "asiyst-bubble";
|
|
2504
2704
|
this.bubble.hidden = true;
|
|
2505
|
-
this.
|
|
2705
|
+
this.chatActionBtn = doc.createElement("button");
|
|
2706
|
+
this.chatActionBtn.type = "button";
|
|
2707
|
+
this.chatActionBtn.className = "asiyst-open-chat-btn";
|
|
2708
|
+
this.chatActionBtn.innerHTML = `
|
|
2709
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
2710
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
2711
|
+
</svg>
|
|
2712
|
+
<span>Chat with ${config.avatarName}</span>
|
|
2713
|
+
`;
|
|
2714
|
+
this.chatActionBtn.addEventListener("click", (e) => {
|
|
2715
|
+
e.stopPropagation();
|
|
2716
|
+
this.onOpenChat?.();
|
|
2717
|
+
});
|
|
2718
|
+
this.figure.addEventListener("click", () => {
|
|
2719
|
+
this.onOpenChat?.();
|
|
2720
|
+
});
|
|
2721
|
+
this.root.append(this.bubble, this.nameTagEl, this.figure, this.chatActionBtn);
|
|
2506
2722
|
container.appendChild(this.root);
|
|
2507
2723
|
this.applyConfig(config);
|
|
2508
2724
|
}
|
|
@@ -2516,24 +2732,51 @@ var CssAvatarRenderer = class {
|
|
|
2516
2732
|
this.root = void 0;
|
|
2517
2733
|
this.figure = void 0;
|
|
2518
2734
|
this.viewport = void 0;
|
|
2735
|
+
this.nameTagEl = void 0;
|
|
2736
|
+
this.chatActionBtn = void 0;
|
|
2519
2737
|
}
|
|
2520
2738
|
applyConfig(config) {
|
|
2521
2739
|
this.size = config.size;
|
|
2522
2740
|
this.accentColor = config.theme.accent ?? "#2563eb";
|
|
2523
2741
|
this.avatarName = config.avatarName;
|
|
2524
|
-
if (this.
|
|
2525
|
-
this.
|
|
2526
|
-
this.figure.style.height = `${config.size}px`;
|
|
2527
|
-
this.figure.style.background = this.accentColor;
|
|
2742
|
+
if (this.nameTextEl) {
|
|
2743
|
+
renderSafeText(this.nameTextEl, config.avatarName);
|
|
2528
2744
|
}
|
|
2529
|
-
if (this.
|
|
2530
|
-
|
|
2745
|
+
if (this.chatActionBtn) {
|
|
2746
|
+
const span = this.chatActionBtn.querySelector("span");
|
|
2747
|
+
if (span) {
|
|
2748
|
+
renderSafeText(span, `Chat with ${config.avatarName}`);
|
|
2749
|
+
}
|
|
2531
2750
|
}
|
|
2532
2751
|
if (this.root) {
|
|
2533
2752
|
this.root.setAttribute("aria-label", config.avatarName);
|
|
2534
2753
|
}
|
|
2535
|
-
if (!this.isAssetLoadedFlag
|
|
2536
|
-
this.
|
|
2754
|
+
if (!this.isAssetLoadedFlag) {
|
|
2755
|
+
if (this.figure) {
|
|
2756
|
+
this.figure.classList.remove("asiyst-3d-active");
|
|
2757
|
+
this.figure.style.width = `${config.size}px`;
|
|
2758
|
+
this.figure.style.height = `${config.size}px`;
|
|
2759
|
+
this.figure.style.background = this.accentColor;
|
|
2760
|
+
}
|
|
2761
|
+
if (this.chatActionBtn) {
|
|
2762
|
+
this.chatActionBtn.style.display = "none";
|
|
2763
|
+
}
|
|
2764
|
+
if (this.viewport) {
|
|
2765
|
+
this.renderFallback();
|
|
2766
|
+
}
|
|
2767
|
+
} else {
|
|
2768
|
+
if (this.figure) {
|
|
2769
|
+
this.figure.classList.add("asiyst-3d-active");
|
|
2770
|
+
}
|
|
2771
|
+
if (this.chatActionBtn) {
|
|
2772
|
+
this.chatActionBtn.style.display = this.isPanelOpen ? "none" : "inline-flex";
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
setPanelOpen(open) {
|
|
2777
|
+
this.isPanelOpen = open;
|
|
2778
|
+
if (this.chatActionBtn && this.isAssetLoadedFlag) {
|
|
2779
|
+
this.chatActionBtn.style.display = open ? "none" : "inline-flex";
|
|
2537
2780
|
}
|
|
2538
2781
|
}
|
|
2539
2782
|
async loadAsset(config) {
|
|
@@ -2554,7 +2797,7 @@ var CssAvatarRenderer = class {
|
|
|
2554
2797
|
}
|
|
2555
2798
|
this.renderLoader();
|
|
2556
2799
|
try {
|
|
2557
|
-
const asset = await this.assetLoader.load(assetUrl);
|
|
2800
|
+
const asset = await this.assetLoader.load(assetUrl, { timeoutMs: 6e4 });
|
|
2558
2801
|
await this.renderLoadedAsset(asset, config);
|
|
2559
2802
|
this.renderState = "ready";
|
|
2560
2803
|
this.isAssetLoadedFlag = true;
|
|
@@ -2562,6 +2805,13 @@ var CssAvatarRenderer = class {
|
|
|
2562
2805
|
this.loadedFormat = asset.format;
|
|
2563
2806
|
if (this.figure) {
|
|
2564
2807
|
this.figure.setAttribute("data-state", "ready");
|
|
2808
|
+
this.figure.classList.add("asiyst-3d-active");
|
|
2809
|
+
this.figure.style.width = "";
|
|
2810
|
+
this.figure.style.height = "";
|
|
2811
|
+
this.figure.style.background = "transparent";
|
|
2812
|
+
}
|
|
2813
|
+
if (this.chatActionBtn) {
|
|
2814
|
+
this.chatActionBtn.style.display = this.isPanelOpen ? "none" : "inline-flex";
|
|
2565
2815
|
}
|
|
2566
2816
|
return true;
|
|
2567
2817
|
} catch (err) {
|
|
@@ -2572,6 +2822,13 @@ var CssAvatarRenderer = class {
|
|
|
2572
2822
|
this.isFallbackFlag = true;
|
|
2573
2823
|
if (this.figure) {
|
|
2574
2824
|
this.figure.setAttribute("data-state", "error");
|
|
2825
|
+
this.figure.classList.remove("asiyst-3d-active");
|
|
2826
|
+
this.figure.style.width = `${this.size}px`;
|
|
2827
|
+
this.figure.style.height = `${this.size}px`;
|
|
2828
|
+
this.figure.style.background = this.accentColor;
|
|
2829
|
+
}
|
|
2830
|
+
if (this.chatActionBtn) {
|
|
2831
|
+
this.chatActionBtn.style.display = "none";
|
|
2575
2832
|
}
|
|
2576
2833
|
this.renderFallback(true);
|
|
2577
2834
|
return false;
|
|
@@ -2593,10 +2850,15 @@ var CssAvatarRenderer = class {
|
|
|
2593
2850
|
this.fbxRenderer = null;
|
|
2594
2851
|
}
|
|
2595
2852
|
if (asset.format === "fbx" || asset.format === "glb") {
|
|
2853
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2854
|
+
const width = isMobile ? 180 : 240;
|
|
2855
|
+
const height = isMobile ? 360 : 460;
|
|
2596
2856
|
this.fbxRenderer = new FbxRenderer();
|
|
2597
2857
|
this.renderMetrics = await this.fbxRenderer.mount(this.viewport, asset, {
|
|
2598
2858
|
accentColor: this.accentColor,
|
|
2599
|
-
config
|
|
2859
|
+
config,
|
|
2860
|
+
width,
|
|
2861
|
+
height
|
|
2600
2862
|
});
|
|
2601
2863
|
this.fbxRenderer.setFacing(this.facing);
|
|
2602
2864
|
this.fbxRenderer.setPose(this.pose);
|
|
@@ -2612,7 +2874,7 @@ var CssAvatarRenderer = class {
|
|
|
2612
2874
|
const thumb = typeof asset.manifest.thumbnailUrl === "string" ? asset.manifest.thumbnailUrl : void 0;
|
|
2613
2875
|
const modelUrl = typeof asset.manifest.assetUrl === "string" ? asset.manifest.assetUrl : typeof asset.manifest.modelUrl === "string" ? asset.manifest.modelUrl : void 0;
|
|
2614
2876
|
if (modelUrl) {
|
|
2615
|
-
const subAsset = await this.assetLoader.load(modelUrl);
|
|
2877
|
+
const subAsset = await this.assetLoader.load(modelUrl, { timeoutMs: 6e4 });
|
|
2616
2878
|
await this.renderLoadedAsset(subAsset, config);
|
|
2617
2879
|
} else if (thumb) {
|
|
2618
2880
|
this.viewport.replaceChildren();
|
|
@@ -2644,7 +2906,6 @@ var CssAvatarRenderer = class {
|
|
|
2644
2906
|
if (isError) {
|
|
2645
2907
|
const badge = doc.createElement("span");
|
|
2646
2908
|
badge.className = "asiyst-avatar-fallback-badge";
|
|
2647
|
-
badge.setAttribute("title", "Avatar asset failed to load");
|
|
2648
2909
|
badge.textContent = "!";
|
|
2649
2910
|
fallback.appendChild(badge);
|
|
2650
2911
|
}
|
|
@@ -2652,66 +2913,72 @@ var CssAvatarRenderer = class {
|
|
|
2652
2913
|
}
|
|
2653
2914
|
setPosition(x, y, animate) {
|
|
2654
2915
|
if (!this.root) return;
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2916
|
+
if (animate) {
|
|
2917
|
+
this.root.classList.add("asiyst-animate");
|
|
2918
|
+
} else {
|
|
2919
|
+
this.root.classList.remove("asiyst-animate");
|
|
2920
|
+
}
|
|
2921
|
+
this.root.style.left = `${Math.round(x)}px`;
|
|
2922
|
+
this.root.style.top = `${Math.round(y)}px`;
|
|
2658
2923
|
}
|
|
2659
2924
|
setFacing(direction) {
|
|
2660
2925
|
this.facing = direction;
|
|
2661
2926
|
this.fbxRenderer?.setFacing(direction);
|
|
2662
|
-
this.syncTransform();
|
|
2663
2927
|
}
|
|
2664
2928
|
setPose(pose) {
|
|
2665
2929
|
this.pose = pose;
|
|
2930
|
+
if (this.figure) {
|
|
2931
|
+
this.figure.setAttribute("data-pose", pose);
|
|
2932
|
+
}
|
|
2933
|
+
if (this.statusTextEl) {
|
|
2934
|
+
const displayStatus = pose === "speak" ? "(SPEAKING)" : pose === "think" ? "(THINKING)" : pose === "celebrate" ? "(CELEBRATING)" : "(IDLE)";
|
|
2935
|
+
this.statusTextEl.textContent = displayStatus;
|
|
2936
|
+
}
|
|
2666
2937
|
this.fbxRenderer?.setPose(pose);
|
|
2667
|
-
this.figure?.setAttribute("data-pose", pose);
|
|
2668
|
-
this.syncTransform();
|
|
2669
|
-
}
|
|
2670
|
-
syncTransform() {
|
|
2671
|
-
if (!this.figure) return;
|
|
2672
|
-
const face = this.facing === "left" ? "scaleX(-1)" : "";
|
|
2673
|
-
const pose = this.pose === "point" ? "rotate(-12deg)" : this.pose === "celebrate" ? "scale(1.08)" : "";
|
|
2674
|
-
this.figure.style.transform = `${face} ${pose}`.trim();
|
|
2675
2938
|
}
|
|
2676
2939
|
setSpeech(text) {
|
|
2677
2940
|
if (!this.bubble) return;
|
|
2678
2941
|
if (!text) {
|
|
2679
2942
|
this.bubble.hidden = true;
|
|
2680
|
-
this.bubble.
|
|
2943
|
+
this.bubble.replaceChildren();
|
|
2681
2944
|
return;
|
|
2682
2945
|
}
|
|
2683
2946
|
this.bubble.hidden = false;
|
|
2684
2947
|
renderSafeText(this.bubble, text);
|
|
2685
2948
|
}
|
|
2686
2949
|
getSize() {
|
|
2950
|
+
if (this.isAssetLoadedFlag && (this.loadedFormat === "fbx" || this.loadedFormat === "glb")) {
|
|
2951
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2952
|
+
return { width: isMobile ? 180 : 240, height: isMobile ? 390 : 490 };
|
|
2953
|
+
}
|
|
2687
2954
|
return { width: this.size, height: this.size + 28 };
|
|
2688
2955
|
}
|
|
2689
2956
|
setHidden(hidden) {
|
|
2690
2957
|
this.hidden = hidden;
|
|
2691
2958
|
if (this.root) {
|
|
2692
|
-
this.root.
|
|
2959
|
+
this.root.style.display = hidden ? "none" : "";
|
|
2693
2960
|
}
|
|
2694
2961
|
}
|
|
2695
2962
|
isHidden() {
|
|
2696
2963
|
return this.hidden;
|
|
2697
2964
|
}
|
|
2698
|
-
|
|
2699
|
-
return this.
|
|
2700
|
-
}
|
|
2701
|
-
getViewport() {
|
|
2702
|
-
return this.viewport;
|
|
2965
|
+
getRenderState() {
|
|
2966
|
+
return this.renderState;
|
|
2703
2967
|
}
|
|
2704
2968
|
isAssetLoaded() {
|
|
2705
2969
|
return this.isAssetLoadedFlag;
|
|
2706
2970
|
}
|
|
2707
|
-
|
|
2708
|
-
return this.
|
|
2971
|
+
getViewport() {
|
|
2972
|
+
return this.viewport;
|
|
2973
|
+
}
|
|
2974
|
+
isFallback() {
|
|
2975
|
+
return this.isFallbackFlag;
|
|
2709
2976
|
}
|
|
2710
2977
|
isFallbackActive() {
|
|
2711
2978
|
return this.isFallbackFlag;
|
|
2712
2979
|
}
|
|
2713
|
-
|
|
2714
|
-
return this.
|
|
2980
|
+
isRendered() {
|
|
2981
|
+
return this.isAssetLoadedFlag && (this.fbxRenderer ? this.fbxRenderer.isRendered() : true);
|
|
2715
2982
|
}
|
|
2716
2983
|
getLoadedFormat() {
|
|
2717
2984
|
return this.loadedFormat;
|
|
@@ -2725,6 +2992,18 @@ var CssAvatarRenderer = class {
|
|
|
2725
2992
|
getMetrics() {
|
|
2726
2993
|
return this.renderMetrics;
|
|
2727
2994
|
}
|
|
2995
|
+
getFigure() {
|
|
2996
|
+
return this.figure;
|
|
2997
|
+
}
|
|
2998
|
+
getFbxRenderer() {
|
|
2999
|
+
return this.fbxRenderer;
|
|
3000
|
+
}
|
|
3001
|
+
getChatActionBtn() {
|
|
3002
|
+
return this.chatActionBtn;
|
|
3003
|
+
}
|
|
3004
|
+
getNameTag() {
|
|
3005
|
+
return this.nameTagEl;
|
|
3006
|
+
}
|
|
2728
3007
|
};
|
|
2729
3008
|
|
|
2730
3009
|
// src/accessibility/a11y.ts
|
|
@@ -2908,6 +3187,8 @@ var MovementEngine = class {
|
|
|
2908
3187
|
this.onViewport = throttle(() => {
|
|
2909
3188
|
if (this.followTarget) {
|
|
2910
3189
|
this.placeBeside(this.followTarget, false);
|
|
3190
|
+
} else {
|
|
3191
|
+
this.goToAnchor();
|
|
2911
3192
|
}
|
|
2912
3193
|
}, VIEWPORT_HANDLER_THROTTLE_MS);
|
|
2913
3194
|
}
|
|
@@ -3525,27 +3806,39 @@ var ConversationPanel = class {
|
|
|
3525
3806
|
this.style.textContent = `
|
|
3526
3807
|
.asiyst-panel {
|
|
3527
3808
|
position: fixed;
|
|
3528
|
-
right:
|
|
3529
|
-
bottom:
|
|
3530
|
-
width: min(
|
|
3531
|
-
max-height: min(
|
|
3532
|
-
background: #
|
|
3809
|
+
right: 256px;
|
|
3810
|
+
bottom: 20px;
|
|
3811
|
+
width: min(380px, calc(100vw - 280px));
|
|
3812
|
+
max-height: min(560px, 75vh);
|
|
3813
|
+
background: #ffffff;
|
|
3533
3814
|
color: #0f172a;
|
|
3534
|
-
border-radius:
|
|
3535
|
-
box-shadow: 0
|
|
3815
|
+
border-radius: 18px;
|
|
3816
|
+
box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.08);
|
|
3536
3817
|
display: flex;
|
|
3537
3818
|
flex-direction: column;
|
|
3538
|
-
font: 14px/1.45 system-ui, sans-serif;
|
|
3819
|
+
font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3539
3820
|
overflow: hidden;
|
|
3821
|
+
z-index: 100000;
|
|
3822
|
+
transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
|
|
3823
|
+
}
|
|
3824
|
+
@media (max-width: 640px) {
|
|
3825
|
+
.asiyst-panel {
|
|
3826
|
+
right: 12px;
|
|
3827
|
+
bottom: 12px;
|
|
3828
|
+
left: 12px;
|
|
3829
|
+
width: auto;
|
|
3830
|
+
max-height: 70vh;
|
|
3831
|
+
}
|
|
3540
3832
|
}
|
|
3541
3833
|
.asiyst-panel[hidden] { display: none; }
|
|
3542
3834
|
.asiyst-panel header {
|
|
3543
3835
|
display: flex;
|
|
3544
3836
|
justify-content: space-between;
|
|
3545
3837
|
align-items: center;
|
|
3546
|
-
padding:
|
|
3838
|
+
padding: 14px 16px;
|
|
3547
3839
|
background: #0f172a;
|
|
3548
3840
|
color: #f8fafc;
|
|
3841
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
|
3549
3842
|
}
|
|
3550
3843
|
.asiyst-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
|
|
3551
3844
|
.asiyst-msg { padding: 8px 10px; border-radius: 10px; max-width: 90%; }
|
|
@@ -3945,6 +4238,7 @@ var AsiystRuntime = class {
|
|
|
3945
4238
|
() => this.map.list()
|
|
3946
4239
|
);
|
|
3947
4240
|
this.renderer = new CssAvatarRenderer();
|
|
4241
|
+
this.renderer.onOpenChat = () => this.open();
|
|
3948
4242
|
this.renderer.mount(this.host.chrome, this.config.get());
|
|
3949
4243
|
this.highlights = new HighlightLayer(this.host.overlay, win);
|
|
3950
4244
|
this.movement = new MovementEngine(win, doc, this.renderer, this.resolver, this.events, () => this.config.get());
|
|
@@ -3967,6 +4261,7 @@ var AsiystRuntime = class {
|
|
|
3967
4261
|
(open) => {
|
|
3968
4262
|
const convId = this.panel.getConversationId();
|
|
3969
4263
|
this.cloud.setConversationId(convId);
|
|
4264
|
+
this.renderer.setPanelOpen(open);
|
|
3970
4265
|
if (open) {
|
|
3971
4266
|
this.analytics.track("assistant_opened");
|
|
3972
4267
|
this.events.emit("asiyst:conversation:started", { conversationId: convId });
|
|
@@ -4039,6 +4334,7 @@ var AsiystRuntime = class {
|
|
|
4039
4334
|
try {
|
|
4040
4335
|
const loaded = await this.renderer.loadAsset(cfg);
|
|
4041
4336
|
if (loaded) {
|
|
4337
|
+
this.movement.goToAnchor();
|
|
4042
4338
|
const format = this.renderer.getLoadedFormat();
|
|
4043
4339
|
const assetUrl = this.renderer.getAssetUrl();
|
|
4044
4340
|
const isRendered = this.renderer.isRendered();
|
|
@@ -4106,9 +4402,14 @@ var AsiystRuntime = class {
|
|
|
4106
4402
|
open() {
|
|
4107
4403
|
this.panel.open();
|
|
4108
4404
|
this.avatar.show();
|
|
4405
|
+
this.renderer.setPanelOpen(true);
|
|
4109
4406
|
}
|
|
4110
4407
|
close() {
|
|
4111
4408
|
this.panel.close();
|
|
4409
|
+
this.renderer.setPanelOpen(false);
|
|
4410
|
+
}
|
|
4411
|
+
getRenderer() {
|
|
4412
|
+
return this.renderer;
|
|
4112
4413
|
}
|
|
4113
4414
|
avatarApi() {
|
|
4114
4415
|
return this.avatar;
|