talking-head-studio 0.4.11 → 0.4.12
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/README.md +279 -193
- package/dist/TalkingHead.d.ts +28 -3
- package/dist/TalkingHead.js +21 -2
- package/dist/TalkingHead.web.d.ts +31 -4
- package/dist/TalkingHead.web.js +11 -1
- package/dist/TalkingHeadVisualization.d.ts +22 -0
- package/dist/TalkingHeadVisualization.js +30 -10
- package/dist/api/studioApi.d.ts +12 -1
- package/dist/api/studioApi.js +16 -2
- package/dist/contract.d.ts +14 -0
- package/dist/contract.js +30 -0
- package/dist/core/avatar/avatarCapabilities.d.ts +60 -0
- package/dist/core/avatar/avatarCapabilities.js +100 -0
- package/dist/core/avatar/backends/gaussian.js +6 -4
- package/dist/core/avatar/motion.d.ts +1713 -0
- package/dist/core/avatar/motion.js +550 -0
- package/dist/core/avatar/motionRuntime.d.ts +46 -0
- package/dist/core/avatar/motionRuntime.js +84 -0
- package/dist/core/avatar/schema.d.ts +33 -5
- package/dist/core/avatar/visemes.d.ts +16 -1
- package/dist/core/avatar/visemes.js +48 -1
- package/dist/editor/AvatarCanvas.js +92 -1
- package/dist/editor/AvatarEditor.native.js +1 -0
- package/dist/editor/AvatarModel.js +1 -0
- package/dist/editor/FaceSqueezeEditor.d.ts +3 -1
- package/dist/editor/FaceSqueezeEditor.js +176 -112
- package/dist/editor/FaceSqueezeEditor.web.d.ts +3 -1
- package/dist/editor/FaceSqueezeEditor.web.js +30 -28
- package/dist/editor/RigidAccessory.js +17 -2
- package/dist/editor/SkinnedClothing.js +1 -0
- package/dist/editor/boneLockedDrag.d.ts +11 -0
- package/dist/editor/boneLockedDrag.js +68 -0
- package/dist/editor/boneSnap.web.d.ts +27 -0
- package/dist/editor/boneSnap.web.js +99 -0
- package/dist/editor/index.web.d.ts +10 -0
- package/dist/editor/index.web.js +26 -0
- package/dist/editor/sounds/haha.wav +0 -0
- package/dist/editor/sounds/owie.wav +0 -0
- package/dist/editor/sounds/stop.wav +0 -0
- package/dist/editor/studioTheme.d.ts +14 -14
- package/dist/editor/studioTheme.js +17 -14
- package/dist/editor/types.d.ts +1 -0
- package/dist/html/accessories.d.ts +7 -0
- package/dist/html/accessories.js +149 -0
- package/dist/html/motion.d.ts +1 -0
- package/dist/html/motion.js +189 -0
- package/dist/html/visemes.d.ts +7 -0
- package/dist/html/visemes.js +348 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +55 -732
- package/dist/index.d.ts +7 -3
- package/dist/index.js +17 -1
- package/dist/index.web.d.ts +18 -1
- package/dist/index.web.js +36 -3
- package/dist/sketchfab/api.js +1 -0
- package/dist/sketchfab/glbInspect.d.ts +22 -0
- package/dist/sketchfab/glbInspect.js +58 -0
- package/dist/sketchfab/index.d.ts +3 -0
- package/dist/sketchfab/index.js +8 -1
- package/dist/sketchfab/inspectRemote.d.ts +13 -0
- package/dist/sketchfab/inspectRemote.js +77 -0
- package/dist/sketchfab/types.d.ts +10 -0
- package/dist/studio/AccessoryBrowserScreen.d.ts +6 -0
- package/dist/studio/AccessoryBrowserScreen.js +626 -0
- package/dist/studio/AccessoryPanel.d.ts +10 -0
- package/dist/studio/AccessoryPanel.js +396 -0
- package/dist/studio/AppearancePanel.d.ts +9 -0
- package/dist/studio/AppearancePanel.js +77 -0
- package/dist/studio/AvatarCreatorScreen.d.ts +5 -0
- package/dist/studio/AvatarCreatorScreen.js +806 -0
- package/dist/studio/AvatarEditorScreen.d.ts +14 -0
- package/dist/studio/AvatarEditorScreen.js +510 -0
- package/dist/studio/AvatarGrid.d.ts +23 -0
- package/dist/studio/AvatarGrid.js +257 -0
- package/dist/studio/ColorSwatch.d.ts +8 -0
- package/dist/studio/ColorSwatch.js +100 -0
- package/dist/studio/CreateVoiceProfileSheet.d.ts +8 -0
- package/dist/studio/CreateVoiceProfileSheet.js +242 -0
- package/dist/studio/DetailsPanel.d.ts +15 -0
- package/dist/studio/DetailsPanel.js +239 -0
- package/dist/studio/FilamentEditor.d.ts +2 -0
- package/dist/studio/FilamentEditor.js +6 -0
- package/dist/studio/PrecisionPanel.d.ts +2 -0
- package/dist/studio/PrecisionPanel.js +7 -0
- package/dist/studio/PublicGalleryScreen.d.ts +5 -0
- package/dist/studio/PublicGalleryScreen.js +358 -0
- package/dist/studio/SketchfabModelCard.d.ts +20 -0
- package/dist/studio/SketchfabModelCard.js +104 -0
- package/dist/studio/StudioBrowseHeader.d.ts +9 -0
- package/dist/studio/StudioBrowseHeader.js +28 -0
- package/dist/studio/StudioEmptyState.d.ts +8 -0
- package/dist/studio/StudioEmptyState.js +29 -0
- package/dist/studio/StudioFloatingAction.d.ts +13 -0
- package/dist/studio/StudioFloatingAction.js +42 -0
- package/dist/studio/StudioSectionHeader.d.ts +7 -0
- package/dist/studio/StudioSectionHeader.js +27 -0
- package/dist/studio/StudioSurfaceCard.d.ts +8 -0
- package/dist/studio/StudioSurfaceCard.js +20 -0
- package/dist/studio/VoicePanel.d.ts +15 -0
- package/dist/studio/VoicePanel.js +305 -0
- package/dist/studio/constants.d.ts +3 -0
- package/dist/studio/constants.js +6 -0
- package/dist/studio/index.d.ts +29 -0
- package/dist/studio/index.js +54 -0
- package/dist/studio/useSketchfabCapabilities.d.ts +31 -0
- package/dist/studio/useSketchfabCapabilities.js +82 -0
- package/dist/tts/useDirectVisemeStream.js +15 -10
- package/dist/utils/avatarUtils.js +92 -5
- package/dist/utils/faceLandmarkerToShapeWeights.js +2 -4
- package/dist/voice/useAudioPlayer.js +17 -4
- package/dist/voice/useVoicePreview.js +4 -2
- package/dist/wardrobe/index.d.ts +1 -0
- package/dist/wardrobe/index.js +6 -1
- package/dist/wardrobe/useAccessoryGestures.d.ts +20 -0
- package/dist/wardrobe/useAccessoryGestures.js +94 -0
- package/dist/wardrobe/useAvatarWardrobeHydration.js +8 -2
- package/dist/wardrobe/useStudioAvatar.js +11 -2
- package/dist/wardrobe/wardrobeStore.d.ts +2 -0
- package/dist/wardrobe/wardrobeStore.js +12 -2
- package/dist/wgpu/R3FWebGpuCanvas.d.ts +15 -0
- package/dist/wgpu/R3FWebGpuCanvas.js +176 -0
- package/dist/wgpu/WgpuAvatar.d.ts +26 -2
- package/dist/wgpu/WgpuAvatar.js +296 -39
- package/dist/wgpu/accessoryDefaults.d.ts +12 -0
- package/dist/wgpu/accessoryDefaults.js +19 -0
- package/dist/wgpu/blobShim.d.ts +2 -0
- package/dist/wgpu/blobShim.js +191 -0
- package/dist/wgpu/index.d.ts +1 -0
- package/dist/wgpu/index.js +4 -1
- package/dist/wgpu/loadGLTFFromUri.d.ts +2 -0
- package/dist/wgpu/loadGLTFFromUri.js +75 -0
- package/dist/wgpu/morphTables.js +21 -10
- package/dist/wgpu/motionState.d.ts +20 -0
- package/dist/wgpu/motionState.js +31 -0
- package/dist/wgpu/patchThreeForRN.d.ts +28 -0
- package/dist/wgpu/patchThreeForRN.js +292 -0
- package/dist/wgpu/scenePlacement.d.ts +5 -0
- package/dist/wgpu/scenePlacement.js +50 -0
- package/dist/wgpu/useAuthedModelUri.js +4 -2
- package/dist/wgpu/useNativeGLTF.d.ts +7 -0
- package/dist/wgpu/useNativeGLTF.js +36 -0
- package/package.json +97 -31
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.blobBytesStore = void 0;
|
|
37
|
+
// MUST be the very first import in any file that uses GLTFLoader on native.
|
|
38
|
+
// Installed before @react-three/fiber is evaluated so the BlobShim is in place
|
|
39
|
+
// before R3F's polyfills() runs its createObjectURL smoke-test.
|
|
40
|
+
/* eslint-disable @typescript-eslint/no-explicit-any -- This polyfills missing React Native Blob and Three.js globals with dynamic host objects. */
|
|
41
|
+
const react_native_1 = require("react-native");
|
|
42
|
+
const base64_js_1 = require("base64-js");
|
|
43
|
+
const THREE = __importStar(require("three"));
|
|
44
|
+
// ─── Shim legacy THREE APIs removed in three.webgpu.js ───────────────────────
|
|
45
|
+
// three-stdlib (Sky, etc.) calls THREE.UniformsUtils.clone() at module init time.
|
|
46
|
+
// three.webgpu.js dropped UniformsUtils — add it back so three-stdlib doesn't crash.
|
|
47
|
+
if (!THREE.UniformsUtils) {
|
|
48
|
+
function cloneUniforms(src) {
|
|
49
|
+
const dst = {};
|
|
50
|
+
for (const u in src) {
|
|
51
|
+
dst[u] = {};
|
|
52
|
+
for (const p in src[u]) {
|
|
53
|
+
const v = src[u][p];
|
|
54
|
+
if (v && typeof v.clone === 'function') {
|
|
55
|
+
dst[u][p] = v.clone();
|
|
56
|
+
}
|
|
57
|
+
else if (Array.isArray(v)) {
|
|
58
|
+
dst[u][p] = v.slice();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
dst[u][p] = v;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return dst;
|
|
66
|
+
}
|
|
67
|
+
THREE.UniformsUtils = {
|
|
68
|
+
clone: cloneUniforms,
|
|
69
|
+
merge: (uniforms) => {
|
|
70
|
+
const merged = {};
|
|
71
|
+
for (const u of uniforms)
|
|
72
|
+
Object.assign(merged, cloneUniforms(u));
|
|
73
|
+
return merged;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (!THREE.UniformsLib) {
|
|
78
|
+
THREE.UniformsLib = {};
|
|
79
|
+
}
|
|
80
|
+
/** Exported so patchThreeForRN can use the same store when re-patching URL.createObjectURL. */
|
|
81
|
+
exports.blobBytesStore = new WeakMap();
|
|
82
|
+
if (react_native_1.Platform.OS !== 'web') {
|
|
83
|
+
const _OrigBlob = globalThis.Blob;
|
|
84
|
+
const _blobBytes = exports.blobBytesStore;
|
|
85
|
+
const encoder = new TextEncoder();
|
|
86
|
+
function toBytes(part) {
|
|
87
|
+
if (part instanceof ArrayBuffer) {
|
|
88
|
+
return new Uint8Array(part);
|
|
89
|
+
}
|
|
90
|
+
if (ArrayBuffer.isView(part)) {
|
|
91
|
+
return new Uint8Array(part.buffer, part.byteOffset, part.byteLength);
|
|
92
|
+
}
|
|
93
|
+
if (typeof part === 'string') {
|
|
94
|
+
return encoder.encode(part);
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function concatBytes(parts) {
|
|
99
|
+
const chunks = parts.map(toBytes);
|
|
100
|
+
if (chunks.some((chunk) => chunk == null))
|
|
101
|
+
return null;
|
|
102
|
+
const total = chunks.reduce((sum, chunk) => sum + (chunk?.byteLength ?? 0), 0);
|
|
103
|
+
const out = new Uint8Array(total);
|
|
104
|
+
let offset = 0;
|
|
105
|
+
for (const chunk of chunks) {
|
|
106
|
+
out.set(chunk, offset);
|
|
107
|
+
offset += chunk.byteLength;
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
function createFallbackBlob(parts, options) {
|
|
112
|
+
const bytes = concatBytes(parts);
|
|
113
|
+
if (!bytes) {
|
|
114
|
+
throw new Error('[BlobShim] Unable to synthesize Blob from unsupported parts');
|
|
115
|
+
}
|
|
116
|
+
const blob = Object.create(_OrigBlob.prototype ?? Object.prototype);
|
|
117
|
+
Object.defineProperties(blob, {
|
|
118
|
+
type: {
|
|
119
|
+
value: options?.type ?? '',
|
|
120
|
+
enumerable: true,
|
|
121
|
+
},
|
|
122
|
+
size: {
|
|
123
|
+
value: bytes.byteLength,
|
|
124
|
+
enumerable: true,
|
|
125
|
+
},
|
|
126
|
+
arrayBuffer: {
|
|
127
|
+
value: async () => {
|
|
128
|
+
const buffer = new ArrayBuffer(bytes.byteLength);
|
|
129
|
+
new Uint8Array(buffer).set(bytes);
|
|
130
|
+
return buffer;
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
text: {
|
|
134
|
+
value: async () => new TextDecoder().decode(bytes),
|
|
135
|
+
},
|
|
136
|
+
slice: {
|
|
137
|
+
value: (start, end, contentType) => {
|
|
138
|
+
return new Blob([bytes.slice(start ?? 0, end ?? bytes.byteLength)], {
|
|
139
|
+
type: contentType ?? options?.type ?? '',
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
_blobBytes.set(blob, bytes);
|
|
145
|
+
return blob;
|
|
146
|
+
}
|
|
147
|
+
function BlobShim(parts, options) {
|
|
148
|
+
const hasBinaryPart = !!parts?.some((p) => p instanceof ArrayBuffer || ArrayBuffer.isView(p));
|
|
149
|
+
let blob;
|
|
150
|
+
let usedFallback = false;
|
|
151
|
+
try {
|
|
152
|
+
blob = new _OrigBlob(parts, options);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (!hasBinaryPart)
|
|
156
|
+
throw error;
|
|
157
|
+
blob = createFallbackBlob(parts ?? [], options);
|
|
158
|
+
usedFallback = true;
|
|
159
|
+
}
|
|
160
|
+
if (parts) {
|
|
161
|
+
let stashed = usedFallback;
|
|
162
|
+
if (!usedFallback) {
|
|
163
|
+
for (const p of parts) {
|
|
164
|
+
const bytes = toBytes(p);
|
|
165
|
+
if (bytes) {
|
|
166
|
+
_blobBytes.set(blob, bytes);
|
|
167
|
+
stashed = true;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
void stashed;
|
|
173
|
+
}
|
|
174
|
+
return blob;
|
|
175
|
+
}
|
|
176
|
+
BlobShim.prototype = _OrigBlob.prototype;
|
|
177
|
+
Object.defineProperty(BlobShim, Symbol.hasInstance, {
|
|
178
|
+
value: (v) => v instanceof _OrigBlob,
|
|
179
|
+
});
|
|
180
|
+
globalThis.Blob = BlobShim;
|
|
181
|
+
URL.createObjectURL = (blob) => {
|
|
182
|
+
const bytes = _blobBytes.get(blob);
|
|
183
|
+
if (bytes) {
|
|
184
|
+
const mime = blob.type || 'application/octet-stream';
|
|
185
|
+
const b64 = (0, base64_js_1.fromByteArray)(bytes);
|
|
186
|
+
return `data:${mime};base64,${b64}`;
|
|
187
|
+
}
|
|
188
|
+
throw new Error('[BlobShim] createObjectURL: no bytes stashed for this Blob');
|
|
189
|
+
};
|
|
190
|
+
URL.revokeObjectURL = (_url) => { };
|
|
191
|
+
}
|
package/dist/wgpu/index.d.ts
CHANGED
package/dist/wgpu/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WgpuAvatar = void 0;
|
|
3
|
+
exports.BONE_SNAP_DEFAULTS = exports.snapDefaultForCategory = exports.WgpuAvatar = void 0;
|
|
4
4
|
var WgpuAvatar_1 = require("./WgpuAvatar");
|
|
5
5
|
Object.defineProperty(exports, "WgpuAvatar", { enumerable: true, get: function () { return WgpuAvatar_1.WgpuAvatar; } });
|
|
6
|
+
var accessoryDefaults_1 = require("./accessoryDefaults");
|
|
7
|
+
Object.defineProperty(exports, "snapDefaultForCategory", { enumerable: true, get: function () { return accessoryDefaults_1.snapDefaultForCategory; } });
|
|
8
|
+
Object.defineProperty(exports, "BONE_SNAP_DEFAULTS", { enumerable: true, get: function () { return accessoryDefaults_1.BONE_SNAP_DEFAULTS; } });
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadGLTFFromUri = loadGLTFFromUri;
|
|
37
|
+
const react_native_1 = require("react-native");
|
|
38
|
+
const base64_js_1 = require("base64-js");
|
|
39
|
+
const FileSystem = __importStar(require("expo-file-system/legacy"));
|
|
40
|
+
const three_stdlib_1 = require("three-stdlib");
|
|
41
|
+
function toArrayBuffer(bytes) {
|
|
42
|
+
const buffer = new ArrayBuffer(bytes.byteLength);
|
|
43
|
+
new Uint8Array(buffer).set(bytes);
|
|
44
|
+
return buffer;
|
|
45
|
+
}
|
|
46
|
+
function decodeDataUri(uri) {
|
|
47
|
+
const marker = ';base64,';
|
|
48
|
+
const markerIndex = uri.indexOf(marker);
|
|
49
|
+
if (markerIndex < 0) {
|
|
50
|
+
throw new Error('Unsupported data URI encoding for GLB');
|
|
51
|
+
}
|
|
52
|
+
const base64 = uri.slice(markerIndex + marker.length);
|
|
53
|
+
return toArrayBuffer((0, base64_js_1.toByteArray)(base64));
|
|
54
|
+
}
|
|
55
|
+
async function parseArrayBuffer(buffer, path = '') {
|
|
56
|
+
const loader = new three_stdlib_1.GLTFLoader();
|
|
57
|
+
return await new Promise((resolve, reject) => {
|
|
58
|
+
loader.parse(buffer, path, resolve, (error) => {
|
|
59
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async function loadGLTFFromUri(uri) {
|
|
64
|
+
if (react_native_1.Platform.OS !== 'web' && uri.startsWith('data:')) {
|
|
65
|
+
return await parseArrayBuffer(decodeDataUri(uri));
|
|
66
|
+
}
|
|
67
|
+
if (react_native_1.Platform.OS !== 'web' && uri.startsWith('file://')) {
|
|
68
|
+
const base64 = await FileSystem.readAsStringAsync(uri, {
|
|
69
|
+
encoding: FileSystem.EncodingType.Base64,
|
|
70
|
+
});
|
|
71
|
+
return await parseArrayBuffer(toArrayBuffer((0, base64_js_1.toByteArray)(base64)));
|
|
72
|
+
}
|
|
73
|
+
const loader = new three_stdlib_1.GLTFLoader();
|
|
74
|
+
return await loader.loadAsync(uri);
|
|
75
|
+
}
|
package/dist/wgpu/morphTables.js
CHANGED
|
@@ -55,6 +55,27 @@ exports.MOOD_MORPHS = {
|
|
|
55
55
|
noseSneerLeft: 0.3, noseSneerRight: 0.3,
|
|
56
56
|
eyeSquintLeft: 0.2, eyeSquintRight: 0.2,
|
|
57
57
|
},
|
|
58
|
+
fear: {
|
|
59
|
+
eyeWideLeft: 0.6, eyeWideRight: 0.6,
|
|
60
|
+
browInnerUp: 0.7, browOuterUpLeft: 0.3, browOuterUpRight: 0.3,
|
|
61
|
+
mouthStretchLeft: 0.2, mouthStretchRight: 0.2,
|
|
62
|
+
},
|
|
63
|
+
disgust: {
|
|
64
|
+
noseSneerLeft: 0.6, noseSneerRight: 0.6,
|
|
65
|
+
browDownLeft: 0.4, browDownRight: 0.4,
|
|
66
|
+
mouthShrugUpper: 0.3,
|
|
67
|
+
},
|
|
68
|
+
love: {
|
|
69
|
+
mouthSmileLeft: 0.45, mouthSmileRight: 0.45,
|
|
70
|
+
cheekSquintLeft: 0.28, cheekSquintRight: 0.28,
|
|
71
|
+
eyeSquintLeft: 0.12, eyeSquintRight: 0.12,
|
|
72
|
+
browOuterUpLeft: 0.18, browOuterUpRight: 0.18,
|
|
73
|
+
},
|
|
74
|
+
sleep: {
|
|
75
|
+
eyeBlinkLeft: 0.7, eyeBlinkRight: 0.7,
|
|
76
|
+
browInnerUp: 0.12,
|
|
77
|
+
mouthClose: 0.25,
|
|
78
|
+
},
|
|
58
79
|
surprised: {
|
|
59
80
|
eyeWideLeft: 0.5, eyeWideRight: 0.5,
|
|
60
81
|
browInnerUp: 0.5, browOuterUpLeft: 0.4, browOuterUpRight: 0.4,
|
|
@@ -75,16 +96,6 @@ exports.MOOD_MORPHS = {
|
|
|
75
96
|
browInnerUp: 0.45, browDownLeft: 0.25, browDownRight: 0.25,
|
|
76
97
|
mouthFrownLeft: 0.2, mouthFrownRight: 0.2,
|
|
77
98
|
},
|
|
78
|
-
disgust: {
|
|
79
|
-
noseSneerLeft: 0.6, noseSneerRight: 0.6,
|
|
80
|
-
browDownLeft: 0.4, browDownRight: 0.4,
|
|
81
|
-
mouthShrugUpper: 0.3,
|
|
82
|
-
},
|
|
83
|
-
fear: {
|
|
84
|
-
eyeWideLeft: 0.6, eyeWideRight: 0.6,
|
|
85
|
-
browInnerUp: 0.7, browOuterUpLeft: 0.3, browOuterUpRight: 0.3,
|
|
86
|
-
mouthStretchLeft: 0.2, mouthStretchRight: 0.2,
|
|
87
|
-
},
|
|
88
99
|
exhausted: {
|
|
89
100
|
eyeBlinkLeft: 0.4, eyeBlinkRight: 0.4,
|
|
90
101
|
browDownLeft: 0.3, browDownRight: 0.3,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MotionBoneKey, MotionKey } from '../core/avatar/motion';
|
|
2
|
+
import { type MotionBone, type Quat } from '../core/avatar/motionRuntime';
|
|
3
|
+
/**
|
|
4
|
+
* Procedural motion state, shared between the imperative handle and the
|
|
5
|
+
* in-scene frame loop that lazily maps skeleton bones.
|
|
6
|
+
*/
|
|
7
|
+
export interface MotionState {
|
|
8
|
+
/** Active motion key, or null when at rest. */
|
|
9
|
+
key: MotionKey | null;
|
|
10
|
+
/** performance.now() ms when the active motion started. */
|
|
11
|
+
startTime: number;
|
|
12
|
+
/** Lazily-scanned bones for the loaded skeleton. */
|
|
13
|
+
bones: Partial<Record<MotionBoneKey, MotionBone>> | null;
|
|
14
|
+
rest: Partial<Record<MotionBoneKey, Quat>> | null;
|
|
15
|
+
/** Timer id for pose-like motions that auto-revert to rest. */
|
|
16
|
+
autoReturnTimer: ReturnType<typeof setTimeout> | null;
|
|
17
|
+
}
|
|
18
|
+
export declare function createMotionState(): MotionState;
|
|
19
|
+
export declare function stopMotionState(motion: MotionState): void;
|
|
20
|
+
export declare function resetMotionStateForAvatarSwap(motion: MotionState): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMotionState = createMotionState;
|
|
4
|
+
exports.stopMotionState = stopMotionState;
|
|
5
|
+
exports.resetMotionStateForAvatarSwap = resetMotionStateForAvatarSwap;
|
|
6
|
+
const motionRuntime_1 = require("../core/avatar/motionRuntime");
|
|
7
|
+
function createMotionState() {
|
|
8
|
+
return {
|
|
9
|
+
key: null,
|
|
10
|
+
startTime: 0,
|
|
11
|
+
bones: null,
|
|
12
|
+
rest: null,
|
|
13
|
+
autoReturnTimer: null,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function stopMotionState(motion) {
|
|
17
|
+
if (motion.autoReturnTimer) {
|
|
18
|
+
clearTimeout(motion.autoReturnTimer);
|
|
19
|
+
motion.autoReturnTimer = null;
|
|
20
|
+
}
|
|
21
|
+
if (motion.bones && motion.rest) {
|
|
22
|
+
(0, motionRuntime_1.restoreMotionBones)(motion.bones, motion.rest);
|
|
23
|
+
}
|
|
24
|
+
motion.key = null;
|
|
25
|
+
motion.startTime = 0;
|
|
26
|
+
}
|
|
27
|
+
function resetMotionStateForAvatarSwap(motion) {
|
|
28
|
+
stopMotionState(motion);
|
|
29
|
+
motion.bones = null;
|
|
30
|
+
motion.rest = null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* patchThreeForRN — patches Three.js loaders for React Native compatibility.
|
|
3
|
+
*
|
|
4
|
+
* Problem: GLTFLoader (three-stdlib) calls URL.createObjectURL(blob) when
|
|
5
|
+
* extracting embedded textures from a GLB's buffer views. React Native's
|
|
6
|
+
* Hermes / JSC runtime does not implement URL.createObjectURL, so every
|
|
7
|
+
* texture inside the GLB fails with "Cannot create URL for blob!".
|
|
8
|
+
*
|
|
9
|
+
* Fix strategy (3 layers):
|
|
10
|
+
*
|
|
11
|
+
* Layer 1 — URL.createObjectURL polyfill
|
|
12
|
+
* Instead of throwing, store the Blob in a module-level Map under a
|
|
13
|
+
* synthetic "rnblob://<id>" key and return that key as the "URL".
|
|
14
|
+
* URL.revokeObjectURL deletes the entry.
|
|
15
|
+
*
|
|
16
|
+
* Layer 2 — THREE.ImageLoader patch
|
|
17
|
+
* When ImageLoader.load() receives an "rnblob://" URL, retrieve the
|
|
18
|
+
* stored Blob, read it as base64 via FileReader, build a "data:" URI,
|
|
19
|
+
* then set it as img.src so expo-gl can decode it natively.
|
|
20
|
+
*
|
|
21
|
+
* Layer 3 — THREE.TextureLoader / THREE.FileLoader safety net
|
|
22
|
+
* Same interception for any direct TextureLoader usage and for
|
|
23
|
+
* FileLoader which is also used internally by GLTFLoader.
|
|
24
|
+
*
|
|
25
|
+
* Call installThreeRNPatches() once at module load time, before any
|
|
26
|
+
* useGLTF / GLTFLoader usage. Pass debug=true for verbose logging.
|
|
27
|
+
*/
|
|
28
|
+
export declare function installThreeRNPatches(debug?: boolean): void;
|