@pmndrs/viverse 0.2.18 → 0.2.20
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/model/gltf.d.ts +2 -2
- package/dist/model/gltf.js +9 -2
- package/dist/model/index.d.ts +7 -2
- package/dist/model/index.js +7 -2
- package/package.json +1 -1
package/dist/model/gltf.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Object3D, Object3DEventMap } from 'three';
|
|
2
|
-
import { GLTF, GLTFLoader } from 'three/examples/jsm/
|
|
2
|
+
import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
3
3
|
export declare const gltfLoader: GLTFLoader;
|
|
4
|
-
export declare function loadGltfCharacterModel(url: string): Promise<GLTF & {
|
|
4
|
+
export declare function loadGltfCharacterModel(url: string, useDraco?: boolean): Promise<GLTF & {
|
|
5
5
|
scene: Object3D<Object3DEventMap & {
|
|
6
6
|
dispose: {};
|
|
7
7
|
}>;
|
package/dist/model/gltf.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { GLTFLoader } from 'three/examples/jsm/Addons.js';
|
|
2
1
|
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
|
|
2
|
+
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
3
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
3
4
|
export const gltfLoader = new GLTFLoader();
|
|
4
5
|
gltfLoader.setMeshoptDecoder(MeshoptDecoder);
|
|
5
|
-
|
|
6
|
+
let dracoLoader;
|
|
7
|
+
export async function loadGltfCharacterModel(url, useDraco = false) {
|
|
8
|
+
if (useDraco && dracoLoader == null) {
|
|
9
|
+
dracoLoader = new DRACOLoader();
|
|
10
|
+
dracoLoader.setDecoderPath('https://www.gstatic.com/draco/v1/decoders/');
|
|
11
|
+
gltfLoader.setDRACOLoader(dracoLoader);
|
|
12
|
+
}
|
|
6
13
|
return (await gltfLoader.loadAsync(url));
|
|
7
14
|
}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type VRMHumanBoneName } from '@pixiv/three-vrm';
|
|
1
2
|
import { AnimationAction, AnimationMixer, Object3D, Quaternion } from 'three';
|
|
2
3
|
import type { BoneMap } from '../utils.js';
|
|
3
|
-
import type { VRMHumanBoneName } from '@pixiv/three-vrm';
|
|
4
4
|
export { VRMHumanBoneName } from '@pixiv/three-vrm';
|
|
5
5
|
export * from './vrm.js';
|
|
6
6
|
export type CharacterModelOptions = {
|
|
@@ -20,6 +20,10 @@ export type CharacterModelOptions = {
|
|
|
20
20
|
* @default true
|
|
21
21
|
*/
|
|
22
22
|
readonly receiveShadow?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
readonly useDraco?: boolean;
|
|
23
27
|
};
|
|
24
28
|
export declare function flattenCharacterModelOptions(options: Exclude<CharacterModelOptions, false> | undefined): Parameters<typeof loadCharacterModel>;
|
|
25
29
|
export type CharacterModel = {
|
|
@@ -28,4 +32,5 @@ export type CharacterModel = {
|
|
|
28
32
|
currentAnimations: Map<string | undefined, AnimationAction>;
|
|
29
33
|
boneRotationOffset?: Quaternion;
|
|
30
34
|
};
|
|
31
|
-
export declare function loadCharacterModel(url?: string, type?: Exclude<CharacterModelOptions, boolean>['type'], boneRotationOffset?: Quaternion, castShadow?: boolean, receiveShadow?: boolean, boneMap?: BoneMap): Promise<CharacterModel>;
|
|
35
|
+
export declare function loadCharacterModel(url?: string, type?: Exclude<CharacterModelOptions, boolean>['type'], boneRotationOffset?: Quaternion, castShadow?: boolean, receiveShadow?: boolean, boneMap?: BoneMap, useDraco?: boolean): Promise<CharacterModel>;
|
|
36
|
+
export declare function getBone(model: CharacterModel, name: VRMHumanBoneName): Object3D | undefined;
|
package/dist/model/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VRM } from '@pixiv/three-vrm';
|
|
1
2
|
import { AnimationMixer, Euler, Quaternion } from 'three';
|
|
2
3
|
import { loadGltfCharacterModel } from './gltf.js';
|
|
3
4
|
import { loadVrmCharacterModel } from './vrm.js';
|
|
@@ -14,9 +15,10 @@ export function flattenCharacterModelOptions(options) {
|
|
|
14
15
|
options.castShadow,
|
|
15
16
|
options.receiveShadow,
|
|
16
17
|
options.boneMap,
|
|
18
|
+
options.useDraco,
|
|
17
19
|
];
|
|
18
20
|
}
|
|
19
|
-
export async function loadCharacterModel(url, type, boneRotationOffset, castShadow = true, receiveShadow = true, boneMap) {
|
|
21
|
+
export async function loadCharacterModel(url, type, boneRotationOffset, castShadow = true, receiveShadow = true, boneMap, useDraco) {
|
|
20
22
|
let result;
|
|
21
23
|
if (url == null) {
|
|
22
24
|
//prepare loading the default model
|
|
@@ -40,7 +42,7 @@ export async function loadCharacterModel(url, type, boneRotationOffset, castShad
|
|
|
40
42
|
result = await loadVrmCharacterModel(url);
|
|
41
43
|
break;
|
|
42
44
|
case 'gltf':
|
|
43
|
-
result = await loadGltfCharacterModel(url);
|
|
45
|
+
result = await loadGltfCharacterModel(url, useDraco);
|
|
44
46
|
break;
|
|
45
47
|
}
|
|
46
48
|
result.boneRotationOffset = boneRotationOffset;
|
|
@@ -60,3 +62,6 @@ export async function loadCharacterModel(url, type, boneRotationOffset, castShad
|
|
|
60
62
|
result.scene.add(restPose);
|
|
61
63
|
return Object.assign(result, { mixer: new AnimationMixer(result.scene), currentAnimations: new Map() });
|
|
62
64
|
}
|
|
65
|
+
export function getBone(model, name) {
|
|
66
|
+
return model instanceof VRM ? (model.humanoid.getRawBoneNode(name) ?? undefined) : model.scene.getObjectByName(name);
|
|
67
|
+
}
|