@pieai/swimmer-avatar-kit 0.1.0 → 0.2.0
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 +6 -0
- package/dist/materials.d.ts +38 -1
- package/dist/materials.js +19 -1
- package/dist/materials.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,8 +52,14 @@ import {
|
|
|
52
52
|
} from "@pieai/swimmer-avatar-kit";
|
|
53
53
|
import {
|
|
54
54
|
createStudioMaterialLibrary,
|
|
55
|
+
dressScene,
|
|
55
56
|
} from "@pieai/swimmer-avatar-kit/materials";
|
|
56
57
|
|
|
58
|
+
// Optional. `buildAvatar` never touches the scene it is mounted into, so a
|
|
59
|
+
// host that already has lighting keeps it. Call this to get the lighting the
|
|
60
|
+
// reference lab uses: ACES, a key light, hemisphere fill, background, floor.
|
|
61
|
+
dressScene(scene, renderer);
|
|
62
|
+
|
|
57
63
|
const materials = createStudioMaterialLibrary(renderer);
|
|
58
64
|
const avatar = buildAvatar(randomRecipe("user-42"), {
|
|
59
65
|
materialFor: materials.materialFor,
|
package/dist/materials.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Texture, WebGLRenderer } from "three";
|
|
1
|
+
import type { Object3D, Scene, Texture, WebGLRenderer } from "three";
|
|
2
2
|
import type { AvatarMaterialFor, AvatarOption } from "./types.js";
|
|
3
3
|
export interface AvatarMaterialLibrary {
|
|
4
4
|
readonly environment: Texture;
|
|
@@ -18,3 +18,40 @@ export declare const FINISHES: readonly AvatarOption[];
|
|
|
18
18
|
export declare function createGlossMaterialLibrary(environment: Texture, options?: AvatarMaterialLibraryOptions): AvatarMaterialLibrary;
|
|
19
19
|
export declare function createStudioMaterialLibrary(renderer: WebGLRenderer): AvatarMaterialLibrary;
|
|
20
20
|
export declare function acquireStudioMaterialLibrary(renderer: WebGLRenderer): AvatarMaterialLibraryLease;
|
|
21
|
+
export interface AvatarStudioOptions {
|
|
22
|
+
/** Width of the shadow-catching floor, in world units. Default 6.4. */
|
|
23
|
+
span?: number;
|
|
24
|
+
/** How dark the contact pool under the character reads. Default 0.19. */
|
|
25
|
+
pool?: number;
|
|
26
|
+
/**
|
|
27
|
+
* `true` for a floor, `"wall"` for a backdrop a grid of characters can throw
|
|
28
|
+
* short shadows onto, `false` for neither.
|
|
29
|
+
*/
|
|
30
|
+
shadows?: boolean | "wall";
|
|
31
|
+
/** Depth of the backdrop when `shadows` is `"wall"`. Default 1.7. */
|
|
32
|
+
wallZ?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface AvatarStudio {
|
|
35
|
+
/** The key light. */
|
|
36
|
+
readonly key: Object3D;
|
|
37
|
+
/** The shadow-catching ground plane. */
|
|
38
|
+
readonly floor: Object3D;
|
|
39
|
+
/** The backdrop, present only when `shadows` was `"wall"`. */
|
|
40
|
+
readonly wall?: Object3D;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Light a scene the way the generator's own studio does: ACES tone mapping and
|
|
44
|
+
* exposure on the renderer, a key light, hemisphere fill, a background, and a
|
|
45
|
+
* shadow-catching floor.
|
|
46
|
+
*
|
|
47
|
+
* This is deliberately separate from the material library. `Avatar` leases
|
|
48
|
+
* materials and builds a character; it does not touch the scene it is mounted
|
|
49
|
+
* into, because a host that already has its own lighting must not have it
|
|
50
|
+
* overwritten. A host that wants the character to look the way the reference
|
|
51
|
+
* lab looks calls this once, and this is the whole of the difference.
|
|
52
|
+
*
|
|
53
|
+
* It mutates `renderer` and `scene` rather than returning something to mount:
|
|
54
|
+
* tone mapping and shadow-map type are renderer state, and there is no honest
|
|
55
|
+
* way to express them as a returned object.
|
|
56
|
+
*/
|
|
57
|
+
export declare function dressScene(scene: Scene, renderer: WebGLRenderer, options?: AvatarStudioOptions): AvatarStudio;
|
package/dist/materials.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { makeMaterialFactory, MATERIALS, studioEnv, } from "../vendor/kindergrimm/src/gloss/gmedia.js";
|
|
1
|
+
import { dressScene as dressSceneUpstream, makeMaterialFactory, MATERIALS, studioEnv, } from "../vendor/kindergrimm/src/gloss/gmedia.js";
|
|
2
2
|
export const FINISHES = Object.freeze(MATERIALS.map((material) => ({ id: material.id, label: material.label })));
|
|
3
3
|
export function createGlossMaterialLibrary(environment, options = {}) {
|
|
4
4
|
const materialForUpstream = makeMaterialFactory(environment);
|
|
@@ -58,4 +58,22 @@ export function acquireStudioMaterialLibrary(renderer) {
|
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Light a scene the way the generator's own studio does: ACES tone mapping and
|
|
63
|
+
* exposure on the renderer, a key light, hemisphere fill, a background, and a
|
|
64
|
+
* shadow-catching floor.
|
|
65
|
+
*
|
|
66
|
+
* This is deliberately separate from the material library. `Avatar` leases
|
|
67
|
+
* materials and builds a character; it does not touch the scene it is mounted
|
|
68
|
+
* into, because a host that already has its own lighting must not have it
|
|
69
|
+
* overwritten. A host that wants the character to look the way the reference
|
|
70
|
+
* lab looks calls this once, and this is the whole of the difference.
|
|
71
|
+
*
|
|
72
|
+
* It mutates `renderer` and `scene` rather than returning something to mount:
|
|
73
|
+
* tone mapping and shadow-map type are renderer state, and there is no honest
|
|
74
|
+
* way to express them as a returned object.
|
|
75
|
+
*/
|
|
76
|
+
export function dressScene(scene, renderer, options = {}) {
|
|
77
|
+
return dressSceneUpstream(scene, renderer, options);
|
|
78
|
+
}
|
|
61
79
|
//# sourceMappingURL=materials.js.map
|
package/dist/materials.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materials.js","sourceRoot":"","sources":["../src/materials.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,SAAS,GACV,MAAM,2CAA2C,CAAC;AAqBnD,MAAM,CAAC,MAAM,QAAQ,GAA4B,MAAM,CAAC,MAAM,CAC5D,SAAS,CAAC,GAAG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