@webxr-jp/mtoon-atlas 0.3.2 → 0.4.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.
@@ -0,0 +1,146 @@
1
+ import * as THREE from 'three';
2
+
3
+ /**
4
+ * MToonAtlasMaterial 型定義集約
5
+ *
6
+ * パラメータテクスチャ、アトラステクスチャ、スロット属性の型定義
7
+ */
8
+
9
+ /**
10
+ * アウトライン幅モード
11
+ *
12
+ * MToonMaterialのアウトライン描画における幅の計算方式
13
+ */
14
+ type OutlineWidthMode = 'none' | 'worldCoordinates' | 'screenCoordinates';
15
+ /**
16
+ * パラメータセマンティクス定義
17
+ *
18
+ * パラメータテクスチャの各テクセル・チャンネルに対応するセマンティック情報
19
+ */
20
+ type ParameterSemanticId = 'baseColor' | 'opacity' | 'shadeColor' | 'emissiveColor' | 'emissiveIntensity' | 'shadingShift' | 'shadingShiftTextureScale' | 'shadingToony' | 'rimLightingMix' | 'matcapColor' | 'outlineWidth' | 'outlineColor' | 'outlineLightingMix' | 'parametricRimColor' | 'parametricRimLift' | 'parametricRimFresnelPower' | 'uvAnimationScrollX' | 'uvAnimationScrollY' | 'uvAnimationRotation' | 'normalScale';
21
+ /**
22
+ * パラメータセマンティック定義
23
+ *
24
+ * パラメータテクスチャのレイアウト情報
25
+ */
26
+ interface ParameterSemantic {
27
+ id: ParameterSemanticId;
28
+ texel: number;
29
+ channels: readonly ('r' | 'g' | 'b' | 'a')[];
30
+ }
31
+ /**
32
+ * 既定のパラメータテクスチャレイアウト
33
+ *
34
+ * スロット(行)ごとに 9 テクセル(列)を持ち、各テクセルの RGBA に
35
+ * 下表のパラメータを詰める。avatar-optimizer の PARAMETER_LAYOUT と同一で、
36
+ * GLSL 版(shaders/mtoon.frag)のテクセル割り当てとも一致させること。
37
+ *
38
+ * shadingShift は -1〜1 を 0〜1 に詰めて保存しているため、
39
+ * 読み出し側で `value * 2 - 1` して復元する。
40
+ */
41
+ declare const DEFAULT_PARAMETER_LAYOUT: readonly ParameterSemantic[];
42
+ /**
43
+ * パラメータテクスチャディスクリプタ
44
+ *
45
+ * avatar-optimizer で生成されたパラメータテクスチャの情報
46
+ */
47
+ interface ParameterTextureDescriptor {
48
+ /** パック済みパラメータテクスチャ */
49
+ texture: THREE.Texture;
50
+ /** スロット数(= 元のマテリアル数) */
51
+ slotCount: number;
52
+ /** スロットあたりのテクセル数(通常8) */
53
+ texelsPerSlot: number;
54
+ /** カスタムレイアウト定義(省略時はデフォルト) */
55
+ semantics?: ParameterSemantic[];
56
+ /** アトラス化されたテクスチャセット */
57
+ atlasedTextures?: AtlasedTextureSet;
58
+ }
59
+ /**
60
+ * アトラス化テクスチャセット
61
+ *
62
+ * avatar-optimizer で生成されたアトラス化テクスチャの集合
63
+ */
64
+ interface AtlasedTextureSet {
65
+ /** ベースカラーアトラス(MToonMaterial.map) */
66
+ baseColor?: THREE.Texture;
67
+ /** Shade 乗算テクスチャアトラス(shadeMultiplyTexture) */
68
+ shade?: THREE.Texture;
69
+ /** Shading Shift テクスチャアトラス(shadingShiftTexture) */
70
+ shadingShift?: THREE.Texture;
71
+ /** ノーマルマップアトラス(normalMap) */
72
+ normal?: THREE.Texture;
73
+ /** エミッシブマップアトラス(emissiveMap) */
74
+ emissive?: THREE.Texture;
75
+ /** Matcap テクスチャアトラス(matcapTexture) */
76
+ matcap?: THREE.Texture;
77
+ /** Rim 乗算テクスチャアトラス(rimMultiplyTexture) */
78
+ rim?: THREE.Texture;
79
+ /** UV アニメーションマスクテクスチャアトラス(uvAnimationMaskTexture) */
80
+ uvAnimationMask?: THREE.Texture;
81
+ }
82
+ /**
83
+ * マテリアルスロット属性設定
84
+ *
85
+ * 頂点属性経由でマテリアルスロットを指定するための設定
86
+ */
87
+ interface MaterialSlotAttributeConfig {
88
+ /** 属性名(デフォルト: 'mtoonMaterialSlot') */
89
+ name: string;
90
+ /** 説明(オプション) */
91
+ description?: string;
92
+ }
93
+ /**
94
+ * MToonAtlasMaterial オプション
95
+ *
96
+ * THREE.ShaderMaterialParameters を拡張した、インスタンシング対応オプション
97
+ */
98
+ interface MToonAtlasOptions extends THREE.ShaderMaterialParameters {
99
+ /** ベースカラー */
100
+ color?: THREE.ColorRepresentation;
101
+ /** エミッシブカラー */
102
+ emissive?: THREE.ColorRepresentation;
103
+ /** エミッシブ強度 */
104
+ emissiveIntensity?: number;
105
+ /** 透明度 */
106
+ transparent?: boolean;
107
+ /** 深度書き込み */
108
+ depthWrite?: boolean;
109
+ /** パラメータテクスチャディスクリプタ */
110
+ parameterTexture?: ParameterTextureDescriptor;
111
+ /** スロット属性設定 */
112
+ slotAttribute?: MaterialSlotAttributeConfig;
113
+ }
114
+ /**
115
+ * GLSL 版(MToonAtlasMaterial)と TSL 版(MToonAtlasNodeMaterial)に共通する
116
+ * インターフェース
117
+ *
118
+ * ローダーとエクスポーターはこの範囲だけを使うことで、どちらのマテリアルも扱える
119
+ */
120
+ interface MToonAtlasMaterialLike extends THREE.Material {
121
+ /** 識別フラグ */
122
+ readonly isMToonAtlasMaterial: true;
123
+ /** パラメータテクスチャディスクリプタ */
124
+ readonly parameterTexture: ParameterTextureDescriptor | undefined;
125
+ /** スロット属性設定 */
126
+ readonly slotAttribute: MaterialSlotAttributeConfig;
127
+ /** アウトライン用マテリアルかどうか */
128
+ isOutline: boolean;
129
+ /** アウトライン幅の計算方式 */
130
+ outlineWidthMode: OutlineWidthMode;
131
+ /** このマテリアルを元にアウトライン用マテリアルを作る */
132
+ createOutlineMaterial(widthMode?: Exclude<OutlineWidthMode, 'none'>): MToonAtlasMaterialLike;
133
+ }
134
+ /**
135
+ * MToonAtlasLoaderPlugin が生成するマテリアルのコンストラクタ
136
+ *
137
+ * WebGLRenderer では MToonAtlasMaterial(既定)、WebGPURenderer では
138
+ * `@webxr-jp/mtoon-atlas/nodes` の MToonAtlasNodeMaterial を渡す
139
+ */
140
+ type MToonAtlasMaterialConstructor = new (parameters: {
141
+ parameterTexture?: ParameterTextureDescriptor;
142
+ slotAttribute?: MaterialSlotAttributeConfig;
143
+ name?: string;
144
+ }) => MToonAtlasMaterialLike;
145
+
146
+ export { type AtlasedTextureSet as A, DEFAULT_PARAMETER_LAYOUT as D, type MToonAtlasOptions as M, type OutlineWidthMode as O, type ParameterTextureDescriptor as P, type MaterialSlotAttributeConfig as a, type MToonAtlasMaterialConstructor as b, type ParameterSemanticId as c, type ParameterSemantic as d, type MToonAtlasMaterialLike as e };
@@ -0,0 +1,146 @@
1
+ import * as THREE from 'three';
2
+
3
+ /**
4
+ * MToonAtlasMaterial 型定義集約
5
+ *
6
+ * パラメータテクスチャ、アトラステクスチャ、スロット属性の型定義
7
+ */
8
+
9
+ /**
10
+ * アウトライン幅モード
11
+ *
12
+ * MToonMaterialのアウトライン描画における幅の計算方式
13
+ */
14
+ type OutlineWidthMode = 'none' | 'worldCoordinates' | 'screenCoordinates';
15
+ /**
16
+ * パラメータセマンティクス定義
17
+ *
18
+ * パラメータテクスチャの各テクセル・チャンネルに対応するセマンティック情報
19
+ */
20
+ type ParameterSemanticId = 'baseColor' | 'opacity' | 'shadeColor' | 'emissiveColor' | 'emissiveIntensity' | 'shadingShift' | 'shadingShiftTextureScale' | 'shadingToony' | 'rimLightingMix' | 'matcapColor' | 'outlineWidth' | 'outlineColor' | 'outlineLightingMix' | 'parametricRimColor' | 'parametricRimLift' | 'parametricRimFresnelPower' | 'uvAnimationScrollX' | 'uvAnimationScrollY' | 'uvAnimationRotation' | 'normalScale';
21
+ /**
22
+ * パラメータセマンティック定義
23
+ *
24
+ * パラメータテクスチャのレイアウト情報
25
+ */
26
+ interface ParameterSemantic {
27
+ id: ParameterSemanticId;
28
+ texel: number;
29
+ channels: readonly ('r' | 'g' | 'b' | 'a')[];
30
+ }
31
+ /**
32
+ * 既定のパラメータテクスチャレイアウト
33
+ *
34
+ * スロット(行)ごとに 9 テクセル(列)を持ち、各テクセルの RGBA に
35
+ * 下表のパラメータを詰める。avatar-optimizer の PARAMETER_LAYOUT と同一で、
36
+ * GLSL 版(shaders/mtoon.frag)のテクセル割り当てとも一致させること。
37
+ *
38
+ * shadingShift は -1〜1 を 0〜1 に詰めて保存しているため、
39
+ * 読み出し側で `value * 2 - 1` して復元する。
40
+ */
41
+ declare const DEFAULT_PARAMETER_LAYOUT: readonly ParameterSemantic[];
42
+ /**
43
+ * パラメータテクスチャディスクリプタ
44
+ *
45
+ * avatar-optimizer で生成されたパラメータテクスチャの情報
46
+ */
47
+ interface ParameterTextureDescriptor {
48
+ /** パック済みパラメータテクスチャ */
49
+ texture: THREE.Texture;
50
+ /** スロット数(= 元のマテリアル数) */
51
+ slotCount: number;
52
+ /** スロットあたりのテクセル数(通常8) */
53
+ texelsPerSlot: number;
54
+ /** カスタムレイアウト定義(省略時はデフォルト) */
55
+ semantics?: ParameterSemantic[];
56
+ /** アトラス化されたテクスチャセット */
57
+ atlasedTextures?: AtlasedTextureSet;
58
+ }
59
+ /**
60
+ * アトラス化テクスチャセット
61
+ *
62
+ * avatar-optimizer で生成されたアトラス化テクスチャの集合
63
+ */
64
+ interface AtlasedTextureSet {
65
+ /** ベースカラーアトラス(MToonMaterial.map) */
66
+ baseColor?: THREE.Texture;
67
+ /** Shade 乗算テクスチャアトラス(shadeMultiplyTexture) */
68
+ shade?: THREE.Texture;
69
+ /** Shading Shift テクスチャアトラス(shadingShiftTexture) */
70
+ shadingShift?: THREE.Texture;
71
+ /** ノーマルマップアトラス(normalMap) */
72
+ normal?: THREE.Texture;
73
+ /** エミッシブマップアトラス(emissiveMap) */
74
+ emissive?: THREE.Texture;
75
+ /** Matcap テクスチャアトラス(matcapTexture) */
76
+ matcap?: THREE.Texture;
77
+ /** Rim 乗算テクスチャアトラス(rimMultiplyTexture) */
78
+ rim?: THREE.Texture;
79
+ /** UV アニメーションマスクテクスチャアトラス(uvAnimationMaskTexture) */
80
+ uvAnimationMask?: THREE.Texture;
81
+ }
82
+ /**
83
+ * マテリアルスロット属性設定
84
+ *
85
+ * 頂点属性経由でマテリアルスロットを指定するための設定
86
+ */
87
+ interface MaterialSlotAttributeConfig {
88
+ /** 属性名(デフォルト: 'mtoonMaterialSlot') */
89
+ name: string;
90
+ /** 説明(オプション) */
91
+ description?: string;
92
+ }
93
+ /**
94
+ * MToonAtlasMaterial オプション
95
+ *
96
+ * THREE.ShaderMaterialParameters を拡張した、インスタンシング対応オプション
97
+ */
98
+ interface MToonAtlasOptions extends THREE.ShaderMaterialParameters {
99
+ /** ベースカラー */
100
+ color?: THREE.ColorRepresentation;
101
+ /** エミッシブカラー */
102
+ emissive?: THREE.ColorRepresentation;
103
+ /** エミッシブ強度 */
104
+ emissiveIntensity?: number;
105
+ /** 透明度 */
106
+ transparent?: boolean;
107
+ /** 深度書き込み */
108
+ depthWrite?: boolean;
109
+ /** パラメータテクスチャディスクリプタ */
110
+ parameterTexture?: ParameterTextureDescriptor;
111
+ /** スロット属性設定 */
112
+ slotAttribute?: MaterialSlotAttributeConfig;
113
+ }
114
+ /**
115
+ * GLSL 版(MToonAtlasMaterial)と TSL 版(MToonAtlasNodeMaterial)に共通する
116
+ * インターフェース
117
+ *
118
+ * ローダーとエクスポーターはこの範囲だけを使うことで、どちらのマテリアルも扱える
119
+ */
120
+ interface MToonAtlasMaterialLike extends THREE.Material {
121
+ /** 識別フラグ */
122
+ readonly isMToonAtlasMaterial: true;
123
+ /** パラメータテクスチャディスクリプタ */
124
+ readonly parameterTexture: ParameterTextureDescriptor | undefined;
125
+ /** スロット属性設定 */
126
+ readonly slotAttribute: MaterialSlotAttributeConfig;
127
+ /** アウトライン用マテリアルかどうか */
128
+ isOutline: boolean;
129
+ /** アウトライン幅の計算方式 */
130
+ outlineWidthMode: OutlineWidthMode;
131
+ /** このマテリアルを元にアウトライン用マテリアルを作る */
132
+ createOutlineMaterial(widthMode?: Exclude<OutlineWidthMode, 'none'>): MToonAtlasMaterialLike;
133
+ }
134
+ /**
135
+ * MToonAtlasLoaderPlugin が生成するマテリアルのコンストラクタ
136
+ *
137
+ * WebGLRenderer では MToonAtlasMaterial(既定)、WebGPURenderer では
138
+ * `@webxr-jp/mtoon-atlas/nodes` の MToonAtlasNodeMaterial を渡す
139
+ */
140
+ type MToonAtlasMaterialConstructor = new (parameters: {
141
+ parameterTexture?: ParameterTextureDescriptor;
142
+ slotAttribute?: MaterialSlotAttributeConfig;
143
+ name?: string;
144
+ }) => MToonAtlasMaterialLike;
145
+
146
+ export { type AtlasedTextureSet as A, DEFAULT_PARAMETER_LAYOUT as D, type MToonAtlasOptions as M, type OutlineWidthMode as O, type ParameterTextureDescriptor as P, type MaterialSlotAttributeConfig as a, type MToonAtlasMaterialConstructor as b, type ParameterSemanticId as c, type ParameterSemantic as d, type MToonAtlasMaterialLike as e };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webxr-jp/mtoon-atlas",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "アトラス化したテクスチャのためのMToonMaterial",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,6 +11,11 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
+ },
15
+ "./nodes": {
16
+ "types": "./dist/nodes/index.d.ts",
17
+ "import": "./dist/nodes/index.js",
18
+ "require": "./dist/nodes/index.cjs"
14
19
  }
15
20
  },
16
21
  "files": [
@@ -25,11 +30,11 @@
25
30
  "@pixiv/three-vrm": "^3.4.4",
26
31
  "@pixiv/three-vrm-materials-mtoon": "^3.4.4",
27
32
  "@types/node": "^22.0.0",
28
- "@types/three": "^0.181.0",
33
+ "@types/three": "^0.187.0",
29
34
  "@types/upng-js": "^2.1.5",
30
35
  "esbuild-raw-plugin": "^0.3.1",
31
36
  "jsdom": "^27.3.0",
32
- "three": "^0.181.1",
37
+ "three": "^0.187.0",
33
38
  "tsup": "^8.0.0",
34
39
  "typescript": "^5.0.0",
35
40
  "vitest": "^2.0.0"