@webship.co/workspace 0.0.0-stage → 1.0.0-alpha1
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/PLUGINS.md +249 -0
- package/README.md +379 -2
- package/WORKSPACES.md +69 -0
- package/actions/ai-items.js +293 -0
- package/actions/audio.js +48 -0
- package/actions/build-order.js +79 -0
- package/actions/checks.js +95 -0
- package/actions/claude-session.js +104 -0
- package/actions/commands-center.js +258 -0
- package/actions/composer.js +267 -0
- package/actions/ddev-addons.js +90 -0
- package/actions/ddev-mail.js +80 -0
- package/actions/ddev.js +237 -0
- package/actions/folders.js +165 -0
- package/actions/graphs.js +107 -0
- package/actions/images-svg.js +33 -0
- package/actions/images.js +145 -0
- package/actions/navigation.js +190 -0
- package/actions/node.js +222 -0
- package/actions/notes.js +55 -0
- package/actions/obsidian.js +59 -0
- package/actions/plugins.js +36 -0
- package/actions/project-make.js +28 -0
- package/actions/rag.js +202 -0
- package/actions/row-actions.js +262 -0
- package/actions/screens.js +270 -0
- package/actions/testing.js +121 -0
- package/actions/video-edit.js +54 -0
- package/ai-inventory.js +182 -0
- package/ai-items.js +202 -0
- package/assistant-cast.js +176 -0
- package/assistant-suggestions.js +91 -0
- package/assistant.js +484 -0
- package/audio-voice.js +528 -0
- package/auth-google.js +260 -0
- package/build-ai.js +52 -0
- package/build-order-page.js +191 -0
- package/build-order.js +313 -0
- package/builder-args.js +117 -0
- package/changelog.js +302 -0
- package/chat-threads.js +134 -0
- package/checks.js +105 -0
- package/claude-args.js +282 -0
- package/claude-sessions.js +129 -0
- package/command-author.js +117 -0
- package/command-block.js +20 -0
- package/commands/defaults.yml +159 -0
- package/commands-page.js +460 -0
- package/commands.js +568 -0
- package/cucumber.js +43 -0
- package/ddev-addons-page.js +124 -0
- package/ddev-addons.js +154 -0
- package/ddev-custom-commands.js +96 -0
- package/ddev-domains.js +84 -0
- package/ddev-import.js +93 -0
- package/ddev-mail-page.js +167 -0
- package/ddev-mail.js +110 -0
- package/ddev-options.js +145 -0
- package/ddev-snapshots.js +126 -0
- package/ddev.js +145 -0
- package/docs/DEVELOPER-GUIDE.md +224 -0
- package/docs/README.md +252 -0
- package/docs/REFERENCE.md +684 -0
- package/docs/USER-GUIDE.md +697 -0
- package/docs/screenshots/assistant/avatar-board.png +0 -0
- package/docs/screenshots/assistant/avatar-coffee.png +0 -0
- package/docs/screenshots/assistant/avatar-colours.png +0 -0
- package/docs/screenshots/assistant/avatar-icons.png +0 -0
- package/docs/screenshots/assistant/avatar-moves.png +0 -0
- package/docs/screenshots/assistant/avatar-pick-cookieman.png +0 -0
- package/docs/screenshots/assistant/avatar-settings-voices.png +0 -0
- package/docs/screenshots/assistant/avatar-status.png +0 -0
- package/docs/screenshots/create-card/create-card.png +0 -0
- package/docs/screenshots/create-card/start-ai.png +0 -0
- package/docs/screenshots/guide-clone-address.png +0 -0
- package/docs/screenshots/guide-clone-worktree-off.png +0 -0
- package/docs/screenshots/guide-clone-worktree-on.png +0 -0
- package/docs/screenshots/guide-ddev-menu.png +0 -0
- package/docs/screenshots/guide-domains.png +0 -0
- package/docs/screenshots/guide-home.png +0 -0
- package/docs/screenshots/guide-ide-menu.png +0 -0
- package/docs/screenshots/guide-remove-refusal.png +0 -0
- package/docs/screenshots/guide-rows-worktree.png +0 -0
- package/docs/screenshots/guide-screens.png +0 -0
- package/docs/screenshots/guide-settings.png +0 -0
- package/docs/screenshots/guide-workspace-page.png +0 -0
- package/docs/screenshots/home/card-settings.png +0 -0
- package/docs/screenshots/home/drag-reorder.png +0 -0
- package/docs/screenshots/home/edit-card.png +0 -0
- package/docs/screenshots/images/claude-code-image.png +0 -0
- package/docs/screenshots/images/edit-with-ai.png +0 -0
- package/docs/screenshots/images/gallery.png +0 -0
- package/docs/screenshots/images/generate-description.png +0 -0
- package/docs/screenshots/images/generate-plan.png +0 -0
- package/docs/screenshots/images/providers.png +0 -0
- package/docs/screenshots/images/svg-form.png +0 -0
- package/docs/screenshots/images/svg-result.png +0 -0
- package/docs/screenshots/images/upload.png +0 -0
- package/docs/screenshots/new-folder/2-form.png +0 -0
- package/docs/screenshots/new-folder/8-ddev-options.png +0 -0
- package/docs/screenshots/new-folder/files-folder.png +0 -0
- package/docs/screenshots/projects/ddev-custom-commands.png +0 -0
- package/docs/screenshots/projects/state-chip-stop.png +0 -0
- package/docs/screenshots/readme/dashboard-dark.png +0 -0
- package/docs/screenshots/readme/dashboard-light.png +0 -0
- package/docs/screenshots/readme/dev-dark.png +0 -0
- package/docs/screenshots/readme/dev-light.png +0 -0
- package/docs/screenshots/readme/docs-dark.png +0 -0
- package/docs/screenshots/readme/docs-light.png +0 -0
- package/docs/screenshots/readme/icons/ai.svg +4 -0
- package/docs/screenshots/readme/icons/code.svg +4 -0
- package/docs/screenshots/readme/icons/docs.svg +4 -0
- package/docs/screenshots/readme/icons/services.svg +4 -0
- package/docs/screenshots/readme/icons/sites.svg +4 -0
- package/docs/screenshots/readme/test-report-dark.png +0 -0
- package/docs/screenshots/readme/test-report-light.png +0 -0
- package/docs/screenshots/readme/test-scenarios.png +0 -0
- package/docs/screenshots/readme/test-steps.png +0 -0
- package/docs/screenshots/readme/videos-dark.png +0 -0
- package/docs/screenshots/readme/videos-light.png +0 -0
- package/docs/screenshots/screens-menu.png +0 -0
- package/docs/screenshots/screens-new.png +0 -0
- package/docs/screenshots/settings/auth-google-lists.png +0 -0
- package/docs/screenshots/settings/delete-1-row.png +0 -0
- package/docs/screenshots/settings/delete-2-confirm.png +0 -0
- package/docs/screenshots/settings/delete-3-type-name.png +0 -0
- package/docs/screenshots/settings/delete-4-type-yes.png +0 -0
- package/event-log.js +59 -0
- package/files-browser.js +247 -0
- package/folders.js +121 -0
- package/format.js +73 -0
- package/git-info.js +81 -0
- package/github-auth.js +62 -0
- package/graphs.js +104 -0
- package/html.js +10 -0
- package/icons.js +83 -0
- package/images-ai.js +447 -0
- package/images-create.js +226 -0
- package/images-page.js +417 -0
- package/images-records.js +39 -0
- package/images-render.js +36 -0
- package/images-svg-core.js +214 -0
- package/images-svg-sanitize.js +188 -0
- package/images-svg.js +241 -0
- package/images.js +270 -0
- package/jobs.js +430 -0
- package/linger.js +21 -0
- package/lists.js +292 -0
- package/media-info.js +136 -0
- package/navigation-page.js +264 -0
- package/navigation.js +394 -0
- package/notes.js +0 -0
- package/obsidian.js +405 -0
- package/package.json +47 -4
- package/palette-index.js +46 -0
- package/playwright.config.js +23 -0
- package/plugin-install.js +239 -0
- package/plugin-loader.js +448 -0
- package/plugin-manifest.js +83 -0
- package/plugin-settings.js +44 -0
- package/plugins/workspace-notes/index.js +59 -0
- package/plugins-page.js +103 -0
- package/project-make.js +241 -0
- package/project-name.js +210 -0
- package/public/assistant-avatar-moves.js +646 -0
- package/public/assistant-avatar-ui.js +1223 -0
- package/public/assistant-avatar.js +530 -0
- package/public/avatar/druplicon.vrm +0 -0
- package/public/css/base.css +260 -0
- package/public/css/components/ai-assistant.css +263 -0
- package/public/css/components/assistant-avatar.css +279 -0
- package/public/css/components/assistant-views.css +198 -0
- package/public/css/components/build-order.css +74 -0
- package/public/css/components/clone-as-a-git-worktree.css +30 -0
- package/public/css/components/command-palette.css +61 -0
- package/public/css/components/commands-center.css +139 -0
- package/public/css/components/confirm-dialog.css +40 -0
- package/public/css/components/create-card.css +8 -0
- package/public/css/components/ddev-menu.css +23 -0
- package/public/css/components/deep-chat.css +17 -0
- package/public/css/components/density.css +11 -0
- package/public/css/components/floating-assistant-workspace-pages.css +55 -0
- package/public/css/components/folders.css +5 -0
- package/public/css/components/full-height-left-assistant-sidebar-all-pages.css +39 -0
- package/public/css/components/full-height-right-actions-rail-pages-that-have-actions.css +267 -0
- package/public/css/components/grid-and-list.css +203 -0
- package/public/css/components/help-page.css +36 -0
- package/public/css/components/hero.css +16 -0
- package/public/css/components/images.css +70 -0
- package/public/css/components/layout-rhythm-and-spacing-polish.css +139 -0
- package/public/css/components/mic-on-any-field-that-wants-typing.css +416 -0
- package/public/css/components/modal-fit.css +113 -0
- package/public/css/components/page-width.css +23 -0
- package/public/css/components/plugins-page.css +9 -0
- package/public/css/components/project-cards.css +256 -0
- package/public/css/components/project-rows.css +390 -0
- package/public/css/components/reordering-the-workspace-cards.css +85 -0
- package/public/css/components/responsive-home-and-the-workspace-pages.css +457 -0
- package/public/css/components/running-commands-as-toasts.css +327 -0
- package/public/css/components/settings-editor-core-config-yml.css +828 -0
- package/public/css/components/short-results-as-a-toast-at-the-top.css +203 -0
- package/public/css/components/sound-player.css +84 -0
- package/public/css/components/suggest-agents-skills-commands.css +112 -0
- package/public/css/components/tab-modal.css +142 -0
- package/public/css/components/terminals.css +244 -0
- package/public/css/components/test-report-media-one-file-per-row-paged.css +144 -0
- package/public/css/components/top-toolbar-logo-breadcrumb.css +107 -0
- package/public/css/components/video-edit.css +6 -0
- package/public/css/components/web-ide-open-with.css +23 -0
- package/public/css/components/working-indicators.css +158 -0
- package/public/css/components/workspace-cards.css +79 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.png +0 -0
- package/public/htmx.min.js +1 -0
- package/public/logo.png +0 -0
- package/public/media-player.js +215 -0
- package/public/mic.js +255 -0
- package/public/narration.js +110 -0
- package/public/palette.js +278 -0
- package/public/sortable.js +251 -0
- package/public/suggest.js +337 -0
- package/public/terminal.js +903 -0
- package/public/themes/default/theme.css +267 -0
- package/public/themes/ember/theme.css +180 -0
- package/public/themes/press/theme.css +290 -0
- package/public/themes/slate/theme.css +182 -0
- package/public/touch-icon.png +0 -0
- package/public/ui.js +2721 -0
- package/public/vendor/ace/LICENSE.txt +24 -0
- package/public/vendor/ace/ace.js +23 -0
- package/public/vendor/ace/ext-language_tools.js +8 -0
- package/public/vendor/ace/ext-searchbox.js +8 -0
- package/public/vendor/ace/mode-css.js +8 -0
- package/public/vendor/ace/mode-html.js +8 -0
- package/public/vendor/ace/mode-javascript.js +8 -0
- package/public/vendor/ace/mode-markdown.js +8 -0
- package/public/vendor/ace/mode-sh.js +8 -0
- package/public/vendor/ace/mode-yaml.js +8 -0
- package/public/vendor/ace/theme-textmate.js +8 -0
- package/public/vendor/ace/theme-tomorrow_night.js +8 -0
- package/public/vendor/ace/worker-yaml.js +1 -0
- package/public/vendor/deep-chat.LICENSE +21 -0
- package/public/vendor/deep-chat.bundle.js +1 -0
- package/public/vendor/fonts/dm-serif-text-LICENSE.txt +93 -0
- package/public/vendor/fonts/dm-serif-text-latin-400-italic.woff2 +0 -0
- package/public/vendor/fonts/dm-serif-text-latin-400-normal.woff2 +0 -0
- package/public/vendor/fonts/figtree-LICENSE.txt +93 -0
- package/public/vendor/fonts/figtree-latin-400-italic.woff2 +0 -0
- package/public/vendor/fonts/figtree-latin-400-normal.woff2 +0 -0
- package/public/vendor/fonts/figtree-latin-600-italic.woff2 +0 -0
- package/public/vendor/fonts/figtree-latin-600-normal.woff2 +0 -0
- package/public/vendor/fonts/jetbrains-mono-LICENSE.txt +93 -0
- package/public/vendor/fonts/jetbrains-mono-latin-400-normal.woff2 +0 -0
- package/public/vendor/fonts/ubuntu-mono-LICENSE.txt +98 -0
- package/public/vendor/fonts/ubuntu-mono-latin-wght-normal.woff2 +0 -0
- package/public/vendor/tabler-LICENSE.txt +21 -0
- package/public/vendor/tabler-sprite.svg +1 -0
- package/public/vendor/three/LICENSE +21 -0
- package/public/vendor/three/addons/loaders/GLTFLoader.js +4860 -0
- package/public/vendor/three/addons/utils/BufferGeometryUtils.js +1501 -0
- package/public/vendor/three/addons/utils/SkeletonUtils.js +496 -0
- package/public/vendor/three/three.core.min.js +6 -0
- package/public/vendor/three/three.module.min.js +6 -0
- package/public/vendor/three-vrm/LICENSE +22 -0
- package/public/vendor/three-vrm/three-vrm.module.min.js +983 -0
- package/public/vendor/uikit-icons.min.js +1 -0
- package/public/vendor/uikit.min.css +1 -0
- package/public/vendor/uikit.min.js +1 -0
- package/public/vendor/webship-icons/ui/bookmark-outlined.svg +1 -0
- package/public/vendor/webship-icons/ui/headset.svg +1 -0
- package/public/vendor/webship-icons/ui/menu.svg +1 -0
- package/public/vendor/webship-icons/ui/pause.svg +1 -0
- package/public/vendor/webship-icons/ui/play.svg +1 -0
- package/public/vendor/webship-icons/ui/share.svg +1 -0
- package/public/vendor/webship-icons/ui/sound-off.svg +1 -0
- package/public/vendor/webship-icons/ui/sound-on.svg +1 -0
- package/public/vendor/webship-icons/ui/stop.svg +1 -0
- package/public/vendor/xterm/addon-fit.js +2 -0
- package/public/vendor/xterm/addon-unicode11.js +2 -0
- package/public/vendor/xterm/addon-web-links.js +2 -0
- package/public/vendor/xterm/xterm.css +218 -0
- package/public/vendor/xterm/xterm.js +2 -0
- package/rag.js +169 -0
- package/reader.js +132 -0
- package/repo-blobs.js +66 -0
- package/report-pdf.js +337 -0
- package/row-layout.js +1440 -0
- package/screenrc +37 -0
- package/screens.js +1063 -0
- package/scripts/code-server-start.sh +190 -0
- package/scripts/images-claude-finish.js +107 -0
- package/scripts/screen-host.sh +114 -0
- package/scripts/screen-runner.js +362 -0
- package/scripts/screen-then.js +47 -0
- package/scripts/update.sh +350 -0
- package/server.js +8140 -0
- package/settings-file.js +423 -0
- package/speech.js +297 -0
- package/tab-modal.js +75 -0
- package/test-reports.js +260 -0
- package/themes.js +381 -0
- package/transcripts.js +168 -0
- package/urls.js +13 -0
- package/validate.js +18 -0
- package/version-check.js +94 -0
- package/video-edit.js +588 -0
- package/waiting.js +85 -0
- package/workspace-card-tools.js +41 -0
- package/workspace-delete.js +139 -0
- package/workspace-types.js +85 -0
- package/workspaces.js +557 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnimationClip,
|
|
3
|
+
AnimationMixer,
|
|
4
|
+
Matrix4,
|
|
5
|
+
Quaternion,
|
|
6
|
+
QuaternionKeyframeTrack,
|
|
7
|
+
SkeletonHelper,
|
|
8
|
+
Vector3,
|
|
9
|
+
VectorKeyframeTrack
|
|
10
|
+
} from 'three';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @module SkeletonUtils
|
|
14
|
+
* @three_import import * as SkeletonUtils from 'three/addons/utils/SkeletonUtils.js';
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
function getBoneName( bone, options ) {
|
|
18
|
+
|
|
19
|
+
if ( options.getBoneName !== undefined ) {
|
|
20
|
+
|
|
21
|
+
return options.getBoneName( bone );
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return options.names[ bone.name ];
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Retargets the skeleton from the given source to the target.
|
|
31
|
+
*
|
|
32
|
+
* Both `target` and `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
|
|
33
|
+
* or a {@link Skeleton} directly.
|
|
34
|
+
*
|
|
35
|
+
* @param {Object3D|Skeleton} target - The target object.
|
|
36
|
+
* @param {Object3D|Skeleton} source - The source object.
|
|
37
|
+
* @param {module:SkeletonUtils~RetargetOptions} options - The options.
|
|
38
|
+
*/
|
|
39
|
+
function retarget( target, source, options = {} ) {
|
|
40
|
+
|
|
41
|
+
const quat = new Quaternion(),
|
|
42
|
+
scale = new Vector3(),
|
|
43
|
+
relativeMatrix = new Matrix4(),
|
|
44
|
+
globalMatrix = new Matrix4();
|
|
45
|
+
|
|
46
|
+
options.preserveBoneMatrix = options.preserveBoneMatrix !== undefined ? options.preserveBoneMatrix : true;
|
|
47
|
+
options.preserveBonePositions = options.preserveBonePositions !== undefined ? options.preserveBonePositions : true;
|
|
48
|
+
options.useTargetMatrix = options.useTargetMatrix !== undefined ? options.useTargetMatrix : false;
|
|
49
|
+
options.hip = options.hip !== undefined ? options.hip : 'hip';
|
|
50
|
+
options.hipInfluence = options.hipInfluence !== undefined ? options.hipInfluence : new Vector3( 1, 1, 1 );
|
|
51
|
+
options.scale = options.scale !== undefined ? options.scale : 1;
|
|
52
|
+
options.names = options.names || {};
|
|
53
|
+
|
|
54
|
+
const sourceBones = source.isObject3D ? source.skeleton.bones : getBones( source ),
|
|
55
|
+
bones = target.isObject3D ? target.skeleton.bones : getBones( target );
|
|
56
|
+
|
|
57
|
+
let bone, name, boneTo,
|
|
58
|
+
bonesPosition;
|
|
59
|
+
|
|
60
|
+
// reset bones
|
|
61
|
+
|
|
62
|
+
if ( target.isObject3D ) {
|
|
63
|
+
|
|
64
|
+
target.skeleton.pose();
|
|
65
|
+
|
|
66
|
+
} else {
|
|
67
|
+
|
|
68
|
+
options.useTargetMatrix = true;
|
|
69
|
+
options.preserveBoneMatrix = false;
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if ( options.preserveBonePositions ) {
|
|
74
|
+
|
|
75
|
+
bonesPosition = [];
|
|
76
|
+
|
|
77
|
+
for ( let i = 0; i < bones.length; i ++ ) {
|
|
78
|
+
|
|
79
|
+
bonesPosition.push( bones[ i ].position.clone() );
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if ( options.preserveBoneMatrix ) {
|
|
86
|
+
|
|
87
|
+
// reset matrix
|
|
88
|
+
|
|
89
|
+
target.updateMatrixWorld();
|
|
90
|
+
|
|
91
|
+
target.matrixWorld.identity();
|
|
92
|
+
|
|
93
|
+
// reset children matrix
|
|
94
|
+
|
|
95
|
+
for ( let i = 0; i < target.children.length; ++ i ) {
|
|
96
|
+
|
|
97
|
+
target.children[ i ].updateMatrixWorld( true );
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for ( let i = 0; i < bones.length; ++ i ) {
|
|
104
|
+
|
|
105
|
+
bone = bones[ i ];
|
|
106
|
+
name = getBoneName( bone, options );
|
|
107
|
+
|
|
108
|
+
boneTo = getBoneByName( name, sourceBones );
|
|
109
|
+
|
|
110
|
+
globalMatrix.copy( bone.matrixWorld );
|
|
111
|
+
|
|
112
|
+
if ( boneTo ) {
|
|
113
|
+
|
|
114
|
+
boneTo.updateMatrixWorld();
|
|
115
|
+
|
|
116
|
+
if ( options.useTargetMatrix ) {
|
|
117
|
+
|
|
118
|
+
relativeMatrix.copy( boneTo.matrixWorld );
|
|
119
|
+
|
|
120
|
+
} else {
|
|
121
|
+
|
|
122
|
+
relativeMatrix.copy( target.matrixWorld ).invert();
|
|
123
|
+
relativeMatrix.multiply( boneTo.matrixWorld );
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ignore scale to extract rotation
|
|
128
|
+
|
|
129
|
+
scale.setFromMatrixScale( relativeMatrix );
|
|
130
|
+
relativeMatrix.scale( scale.set( 1 / scale.x, 1 / scale.y, 1 / scale.z ) );
|
|
131
|
+
|
|
132
|
+
// apply to global matrix
|
|
133
|
+
|
|
134
|
+
globalMatrix.makeRotationFromQuaternion( quat.setFromRotationMatrix( relativeMatrix ) );
|
|
135
|
+
|
|
136
|
+
if ( target.isObject3D ) {
|
|
137
|
+
|
|
138
|
+
if ( options.localOffsets ) {
|
|
139
|
+
|
|
140
|
+
if ( options.localOffsets[ bone.name ] ) {
|
|
141
|
+
|
|
142
|
+
globalMatrix.multiply( options.localOffsets[ bone.name ] );
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
globalMatrix.copyPosition( relativeMatrix );
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if ( name === options.hip ) {
|
|
155
|
+
|
|
156
|
+
globalMatrix.elements[ 12 ] *= options.scale * options.hipInfluence.x;
|
|
157
|
+
globalMatrix.elements[ 13 ] *= options.scale * options.hipInfluence.y;
|
|
158
|
+
globalMatrix.elements[ 14 ] *= options.scale * options.hipInfluence.z;
|
|
159
|
+
|
|
160
|
+
if ( options.hipPosition !== undefined ) {
|
|
161
|
+
|
|
162
|
+
globalMatrix.elements[ 12 ] += options.hipPosition.x * options.scale;
|
|
163
|
+
globalMatrix.elements[ 13 ] += options.hipPosition.y * options.scale;
|
|
164
|
+
globalMatrix.elements[ 14 ] += options.hipPosition.z * options.scale;
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if ( bone.parent ) {
|
|
171
|
+
|
|
172
|
+
bone.matrix.copy( bone.parent.matrixWorld ).invert();
|
|
173
|
+
bone.matrix.multiply( globalMatrix );
|
|
174
|
+
|
|
175
|
+
} else {
|
|
176
|
+
|
|
177
|
+
bone.matrix.copy( globalMatrix );
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
bone.matrix.decompose( bone.position, bone.quaternion, bone.scale );
|
|
182
|
+
|
|
183
|
+
bone.updateMatrixWorld();
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if ( options.preserveBonePositions ) {
|
|
188
|
+
|
|
189
|
+
for ( let i = 0; i < bones.length; ++ i ) {
|
|
190
|
+
|
|
191
|
+
bone = bones[ i ];
|
|
192
|
+
name = getBoneName( bone, options ) || bone.name;
|
|
193
|
+
|
|
194
|
+
if ( name !== options.hip ) {
|
|
195
|
+
|
|
196
|
+
bone.position.copy( bonesPosition[ i ] );
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if ( options.preserveBoneMatrix ) {
|
|
205
|
+
|
|
206
|
+
// restore matrix
|
|
207
|
+
|
|
208
|
+
target.updateMatrixWorld( true );
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Retargets the animation clip of the source to the target 3D object.
|
|
216
|
+
*
|
|
217
|
+
* The `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
|
|
218
|
+
* or a {@link Skeleton} directly.
|
|
219
|
+
*
|
|
220
|
+
* @param {Object3D} target - The target 3D object. Must have a `skeleton` property.
|
|
221
|
+
* @param {Object3D|Skeleton} source - The source object.
|
|
222
|
+
* @param {AnimationClip} clip - The animation clip.
|
|
223
|
+
* @param {module:SkeletonUtils~RetargetOptions} options - The options.
|
|
224
|
+
* @return {AnimationClip} The retargeted animation clip.
|
|
225
|
+
*/
|
|
226
|
+
function retargetClip( target, source, clip, options = {} ) {
|
|
227
|
+
|
|
228
|
+
options.useFirstFramePosition = options.useFirstFramePosition !== undefined ? options.useFirstFramePosition : false;
|
|
229
|
+
|
|
230
|
+
// Calculate the fps from the source clip based on the track with the most frames, unless fps is already provided.
|
|
231
|
+
options.fps = options.fps !== undefined ? options.fps : ( Math.max( ...clip.tracks.map( track => track.times.length ) ) / clip.duration );
|
|
232
|
+
options.names = options.names || [];
|
|
233
|
+
|
|
234
|
+
if ( ! source.isObject3D ) {
|
|
235
|
+
|
|
236
|
+
source = getHelperFromSkeleton( source );
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const numFrames = Math.round( clip.duration * ( options.fps / 1000 ) * 1000 ),
|
|
241
|
+
delta = clip.duration / ( numFrames - 1 ),
|
|
242
|
+
convertedTracks = [],
|
|
243
|
+
mixer = new AnimationMixer( source ),
|
|
244
|
+
bones = getBones( target.skeleton ),
|
|
245
|
+
boneDatas = [];
|
|
246
|
+
|
|
247
|
+
let positionOffset,
|
|
248
|
+
bone, boneTo, boneData,
|
|
249
|
+
name;
|
|
250
|
+
|
|
251
|
+
mixer.clipAction( clip ).play();
|
|
252
|
+
|
|
253
|
+
// trim
|
|
254
|
+
|
|
255
|
+
let start = 0, end = numFrames;
|
|
256
|
+
|
|
257
|
+
if ( options.trim !== undefined ) {
|
|
258
|
+
|
|
259
|
+
start = Math.round( options.trim[ 0 ] * options.fps );
|
|
260
|
+
end = Math.min( Math.round( options.trim[ 1 ] * options.fps ), numFrames ) - start;
|
|
261
|
+
|
|
262
|
+
mixer.update( options.trim[ 0 ] );
|
|
263
|
+
|
|
264
|
+
} else {
|
|
265
|
+
|
|
266
|
+
mixer.update( 0 );
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
source.updateMatrixWorld();
|
|
271
|
+
|
|
272
|
+
//
|
|
273
|
+
|
|
274
|
+
for ( let frame = 0; frame < end; ++ frame ) {
|
|
275
|
+
|
|
276
|
+
const time = frame * delta;
|
|
277
|
+
|
|
278
|
+
retarget( target, source, options );
|
|
279
|
+
|
|
280
|
+
for ( let j = 0; j < bones.length; ++ j ) {
|
|
281
|
+
|
|
282
|
+
bone = bones[ j ];
|
|
283
|
+
name = getBoneName( bone, options ) || bone.name;
|
|
284
|
+
boneTo = getBoneByName( name, source.skeleton );
|
|
285
|
+
|
|
286
|
+
if ( boneTo ) {
|
|
287
|
+
|
|
288
|
+
boneData = boneDatas[ j ] = boneDatas[ j ] || { bone: bone };
|
|
289
|
+
|
|
290
|
+
if ( options.hip === name ) {
|
|
291
|
+
|
|
292
|
+
if ( ! boneData.pos ) {
|
|
293
|
+
|
|
294
|
+
boneData.pos = {
|
|
295
|
+
times: new Float32Array( end ),
|
|
296
|
+
values: new Float32Array( end * 3 )
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if ( options.useFirstFramePosition ) {
|
|
302
|
+
|
|
303
|
+
if ( frame === 0 ) {
|
|
304
|
+
|
|
305
|
+
positionOffset = bone.position.clone();
|
|
306
|
+
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
bone.position.sub( positionOffset );
|
|
310
|
+
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
boneData.pos.times[ frame ] = time;
|
|
314
|
+
|
|
315
|
+
bone.position.toArray( boneData.pos.values, frame * 3 );
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if ( ! boneData.quat ) {
|
|
320
|
+
|
|
321
|
+
boneData.quat = {
|
|
322
|
+
times: new Float32Array( end ),
|
|
323
|
+
values: new Float32Array( end * 4 )
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
boneData.quat.times[ frame ] = time;
|
|
329
|
+
|
|
330
|
+
bone.quaternion.toArray( boneData.quat.values, frame * 4 );
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if ( frame === end - 2 ) {
|
|
337
|
+
|
|
338
|
+
// last mixer update before final loop iteration
|
|
339
|
+
// make sure we do not go over or equal to clip duration
|
|
340
|
+
mixer.update( delta - 0.0000001 );
|
|
341
|
+
|
|
342
|
+
} else {
|
|
343
|
+
|
|
344
|
+
mixer.update( delta );
|
|
345
|
+
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
source.updateMatrixWorld();
|
|
349
|
+
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
for ( let i = 0; i < boneDatas.length; ++ i ) {
|
|
353
|
+
|
|
354
|
+
boneData = boneDatas[ i ];
|
|
355
|
+
|
|
356
|
+
if ( boneData ) {
|
|
357
|
+
|
|
358
|
+
if ( boneData.pos ) {
|
|
359
|
+
|
|
360
|
+
convertedTracks.push( new VectorKeyframeTrack(
|
|
361
|
+
'.bones[' + boneData.bone.name + '].position',
|
|
362
|
+
boneData.pos.times,
|
|
363
|
+
boneData.pos.values
|
|
364
|
+
) );
|
|
365
|
+
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
convertedTracks.push( new QuaternionKeyframeTrack(
|
|
369
|
+
'.bones[' + boneData.bone.name + '].quaternion',
|
|
370
|
+
boneData.quat.times,
|
|
371
|
+
boneData.quat.values
|
|
372
|
+
) );
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
mixer.uncacheAction( clip );
|
|
379
|
+
|
|
380
|
+
return new AnimationClip( clip.name, - 1, convertedTracks );
|
|
381
|
+
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Clones the given 3D object and its descendants, ensuring that any `SkinnedMesh` instances are
|
|
386
|
+
* correctly associated with their bones. Bones are also cloned, and must be descendants of the
|
|
387
|
+
* object passed to this method. Other data, like geometries and materials, are reused by reference.
|
|
388
|
+
*
|
|
389
|
+
* @param {Object3D} source - The 3D object to clone.
|
|
390
|
+
* @return {Object3D} The cloned 3D object.
|
|
391
|
+
*/
|
|
392
|
+
function clone( source ) {
|
|
393
|
+
|
|
394
|
+
const sourceLookup = new Map();
|
|
395
|
+
const cloneLookup = new Map();
|
|
396
|
+
|
|
397
|
+
const clone = source.clone();
|
|
398
|
+
|
|
399
|
+
parallelTraverse( source, clone, function ( sourceNode, clonedNode ) {
|
|
400
|
+
|
|
401
|
+
sourceLookup.set( clonedNode, sourceNode );
|
|
402
|
+
cloneLookup.set( sourceNode, clonedNode );
|
|
403
|
+
|
|
404
|
+
} );
|
|
405
|
+
|
|
406
|
+
clone.traverse( function ( node ) {
|
|
407
|
+
|
|
408
|
+
if ( ! node.isSkinnedMesh ) return;
|
|
409
|
+
|
|
410
|
+
const clonedMesh = node;
|
|
411
|
+
const sourceMesh = sourceLookup.get( node );
|
|
412
|
+
const sourceBones = sourceMesh.skeleton.bones;
|
|
413
|
+
|
|
414
|
+
clonedMesh.skeleton = sourceMesh.skeleton.clone();
|
|
415
|
+
clonedMesh.bindMatrix.copy( sourceMesh.bindMatrix );
|
|
416
|
+
|
|
417
|
+
clonedMesh.skeleton.bones = sourceBones.map( function ( bone ) {
|
|
418
|
+
|
|
419
|
+
return cloneLookup.get( bone );
|
|
420
|
+
|
|
421
|
+
} );
|
|
422
|
+
|
|
423
|
+
clonedMesh.bind( clonedMesh.skeleton, clonedMesh.bindMatrix );
|
|
424
|
+
|
|
425
|
+
} );
|
|
426
|
+
|
|
427
|
+
return clone;
|
|
428
|
+
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// internal helper
|
|
432
|
+
|
|
433
|
+
function getBoneByName( name, skeleton ) {
|
|
434
|
+
|
|
435
|
+
for ( let i = 0, bones = getBones( skeleton ); i < bones.length; i ++ ) {
|
|
436
|
+
|
|
437
|
+
if ( name === bones[ i ].name )
|
|
438
|
+
|
|
439
|
+
return bones[ i ];
|
|
440
|
+
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function getBones( skeleton ) {
|
|
446
|
+
|
|
447
|
+
return Array.isArray( skeleton ) ? skeleton : skeleton.bones;
|
|
448
|
+
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
function getHelperFromSkeleton( skeleton ) {
|
|
453
|
+
|
|
454
|
+
const source = new SkeletonHelper( skeleton.bones[ 0 ] );
|
|
455
|
+
source.skeleton = skeleton;
|
|
456
|
+
|
|
457
|
+
return source;
|
|
458
|
+
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function parallelTraverse( a, b, callback ) {
|
|
462
|
+
|
|
463
|
+
callback( a, b );
|
|
464
|
+
|
|
465
|
+
for ( let i = 0; i < a.children.length; i ++ ) {
|
|
466
|
+
|
|
467
|
+
parallelTraverse( a.children[ i ], b.children[ i ], callback );
|
|
468
|
+
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Retarget options of `SkeletonUtils`.
|
|
475
|
+
*
|
|
476
|
+
* @typedef {Object} module:SkeletonUtils~RetargetOptions
|
|
477
|
+
* @property {boolean} [useFirstFramePosition=false] - Whether to use the position of the first frame or not.
|
|
478
|
+
* @property {number} [fps] - The FPS of the clip.
|
|
479
|
+
* @property {Object<string,string>} [names] - A dictionary for mapping target to source bone names.
|
|
480
|
+
* @property {function(string):string} [getBoneName] - A function for mapping bone names. Alternative to `names`.
|
|
481
|
+
* @property {Array<number>} [trim] - Whether to trim the clip or not. If set the array should hold two values for the start and end.
|
|
482
|
+
* @property {boolean} [preserveBoneMatrix=true] - Whether to preserve bone matrices or not.
|
|
483
|
+
* @property {boolean} [preserveBonePositions=true] - Whether to preserve bone positions or not.
|
|
484
|
+
* @property {boolean} [useTargetMatrix=false] - Whether to use the target matrix or not.
|
|
485
|
+
* @property {string} [hip='hip'] - The name of the source's hip bone.
|
|
486
|
+
* @property {Vector3} [hipInfluence=(1,1,1)] - The hip influence.
|
|
487
|
+
* @property {number} [scale=1] - The scale.
|
|
488
|
+
* @property {Object<string,Matrix4>} [localOffsets] - Per-bone local offset matrices, keyed by bone name.
|
|
489
|
+
* @property {Vector3} [hipPosition] - An additional position offset applied to the hip bone.
|
|
490
|
+
**/
|
|
491
|
+
|
|
492
|
+
export {
|
|
493
|
+
retarget,
|
|
494
|
+
retargetClip,
|
|
495
|
+
clone,
|
|
496
|
+
};
|