@pmndrs/viverse 0.2.18 → 0.2.19

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.
@@ -1,7 +1,7 @@
1
1
  import { Object3D, Object3DEventMap } from 'three';
2
- import { GLTF, GLTFLoader } from 'three/examples/jsm/Addons.js';
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
  }>;
@@ -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
- export async function loadGltfCharacterModel(url) {
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
  }
@@ -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,4 @@ 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>;
@@ -14,9 +14,10 @@ export function flattenCharacterModelOptions(options) {
14
14
  options.castShadow,
15
15
  options.receiveShadow,
16
16
  options.boneMap,
17
+ options.useDraco,
17
18
  ];
18
19
  }
19
- export async function loadCharacterModel(url, type, boneRotationOffset, castShadow = true, receiveShadow = true, boneMap) {
20
+ export async function loadCharacterModel(url, type, boneRotationOffset, castShadow = true, receiveShadow = true, boneMap, useDraco) {
20
21
  let result;
21
22
  if (url == null) {
22
23
  //prepare loading the default model
@@ -40,7 +41,7 @@ export async function loadCharacterModel(url, type, boneRotationOffset, castShad
40
41
  result = await loadVrmCharacterModel(url);
41
42
  break;
42
43
  case 'gltf':
43
- result = await loadGltfCharacterModel(url);
44
+ result = await loadGltfCharacterModel(url, useDraco);
44
45
  break;
45
46
  }
46
47
  result.boneRotationOffset = boneRotationOffset;
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "peerDependencies": {
22
22
  "three": "*"
23
23
  },
24
- "version": "0.2.18",
24
+ "version": "0.2.19",
25
25
  "type": "module",
26
26
  "dependencies": {
27
27
  "@pixiv/three-vrm": "^3.4.2",