@scenoco-three/unity 1.4.0 → 1.6.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/dist/cli.js CHANGED
@@ -2,8 +2,8 @@
2
2
  /**
3
3
  * scenoco-unity <unity-project> [--root <game>] [--headed]
4
4
  *
5
- * Writes the game's prefabs, scenes, meshes and materials into a Unity project: Unity builds them
6
- * with its own API the next time it compiles (or from the menu, SceNoCo ▸ Import).
5
+ * Writes the game's prefabs and scenes into a Unity project as Scenoco's text, with the meshes and
6
+ * materials they name: Unity builds them the next time it compiles (or from the menu, SceNoCo ▸ Import).
7
7
  */
8
8
  import { resolve } from 'node:path';
9
9
  import { snapshotProject, writeUnity } from './export.js';
@@ -34,7 +34,7 @@ if (!project || args.length > 1 || unknown) {
34
34
  }
35
35
  try {
36
36
  const snap = await snapshotProject(root, { headed });
37
- const { converted, scripts, modules, warnings } = await writeUnity(snap, project, root);
37
+ const { converted, twins, packages, scripts, modules, warnings } = await writeUnity(snap, project, root);
38
38
  const d = converted.data;
39
39
  console.log(`${d.prefabs.length} prefabs, ${d.scenes.length} scenes, ${d.meshes.length} meshes, ${d.materials.length} materials → ${resolve(project)}`);
40
40
  if (scripts.length)
@@ -45,8 +45,11 @@ try {
45
45
  console.log(`The page as UXML and USS in Assets/UI: ${Object.values(d.ui.documents).join(', ')}.`);
46
46
  for (const w of warnings)
47
47
  console.log(`warning: ${w}`);
48
- console.log('Porting rules: Assets/SceNoCo/PORTING.md. Driving the game in Play mode: unity command scenoco.help (needs com.unity.pipeline).');
49
- for (const w of d.warnings)
48
+ console.log(`Scenes and prefabs as Scenoco's text: ${twins.join(', ')}.`);
49
+ if (packages.length)
50
+ console.log(`Added to Packages/manifest.json: ${packages.join(', ')}.`);
51
+ console.log('Porting rules: Assets/SceNoCo/PORTING.md. The port is checked with Diceload simulations (its unity-game skill is copied into .claude/skills).');
52
+ for (const w of new Set(d.warnings))
50
53
  console.log(`warning: ${w}`);
51
54
  console.log('Unity builds them when it next compiles, or from SceNoCo ▸ Import.');
52
55
  }
package/dist/convert.d.ts CHANGED
@@ -81,8 +81,14 @@ export interface UnityNode {
81
81
  components: UnityComponent[];
82
82
  /** A nested prefab's asset path. */
83
83
  prefab?: string;
84
+ /** A placed prefab given attributes: what this copy is built as, to compare with the prefab. */
85
+ given?: boolean;
86
+ /** Added under a placed prefab by its tag: an object the copy adds, never one of the prefab's own. */
87
+ added?: boolean;
84
88
  /** Its Unity layer, from a collider's `layer`: SceNoCo's layer n is Unity's user layer n + 7. */
85
89
  layer?: number;
90
+ /** A placed model's objects that hold a mesh, as paths of names from its root, as glTFast names them. */
91
+ meshNodes?: string[][];
86
92
  children: UnityNode[];
87
93
  source?: string;
88
94
  }
@@ -91,6 +97,8 @@ export interface UnityMesh {
91
97
  vertices: number[];
92
98
  normals?: number[];
93
99
  uv?: number[];
100
+ /** Vertex colours, RGBA, linear: a material with `vertexColors` draws them. */
101
+ colors?: number[];
94
102
  /** One triangle list per submesh, wound for Unity. */
95
103
  submeshes: number[][];
96
104
  }
@@ -113,6 +121,8 @@ export interface UnityMaterial {
113
121
  emissionTexture?: string;
114
122
  /** How often the textures repeat: three's `texture.repeat`, Unity's tiling. */
115
123
  tiling?: number[];
124
+ /** Multiplied by the mesh's vertex colours: URP's Particles shaders, which Lit and Unlit are not. */
125
+ vertexColors?: boolean;
116
126
  }
117
127
  /**
118
128
  * A terrain as Unity's `TerrainData` wants it. SceNoCo's is centred on its node with heights in
@@ -132,10 +142,13 @@ export interface UnityTerrain {
132
142
  alphamapResolution: number;
133
143
  /** 0..1, `alphamaps[(y * a + x) * layers + layer]`. */
134
144
  alphamaps: number[];
145
+ /** Each layer's colour, and its textures' asset paths once the exporter copied them in. */
135
146
  layers: {
136
147
  name: string;
137
148
  tileSize: number;
138
149
  color: string;
150
+ texture?: string;
151
+ normalMap?: string;
139
152
  }[];
140
153
  }
141
154
  export interface UnityPrefab {
@@ -185,6 +198,18 @@ export interface UnityExport {
185
198
  };
186
199
  /** The project-wide input actions asset. */
187
200
  input?: string;
201
+ /**
202
+ * A model whose copies differ from Unity's defaults (`sharedModel(url, { castShadow: false })`), as a
203
+ * prefab variant of its file with its renderers set: what its placements and fields name instead.
204
+ */
205
+ modelVariants: {
206
+ path: string;
207
+ model: string;
208
+ castShadow: boolean;
209
+ receiveShadow: boolean;
210
+ }[];
211
+ /** Images a behaviour's field holds — read as data, a height stamp — imported pixel for pixel. */
212
+ dataTextures: string[];
188
213
  warnings: string[];
189
214
  }
190
215
  /** SceNoCo's layers are 0 to 15, Unity's own 0 to 5: layer n, past 0, is Unity's user layer n + 7. */
@@ -215,5 +240,21 @@ export interface ConvertOptions {
215
240
  ignore2D: [number, number][];
216
241
  ignore3D: [number, number][];
217
242
  };
243
+ /** Every type alias the game declares, by name: what a stub's signature that names one means. */
244
+ aliases?: Map<string, string>;
245
+ /** The page's `<template>`s as UXML, by id: `chip` → `Assets/UI/chip.uxml`. */
246
+ templates?: Record<string, string>;
247
+ /** Files the game loads that no field may name — a table of sounds — copied in all the same. */
248
+ files?: {
249
+ url: string;
250
+ type: string;
251
+ }[];
218
252
  }
219
253
  export declare function convert(snap: Snapshot, options?: ConvertOptions): Converted;
254
+ /** The C# type of an asset, by its file: a model imports as a GameObject, as a prefab does. */
255
+ export declare function assetType(path: string): string;
256
+ /**
257
+ * The objects of a .glb that hold a mesh, as glTFast builds them under the model's root: one per node
258
+ * of its scene, named as the node is, or `Node-<index>` when it has no name.
259
+ */
260
+ export declare function glbMeshNodes(file: string): string[][];