@scenoco-three/unity 1.4.0 → 1.5.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 +8 -5
- package/dist/convert.d.ts +39 -0
- package/dist/convert.js +324 -38
- package/dist/export.d.ts +22 -3
- package/dist/export.js +243 -33
- package/dist/page.d.ts +2 -0
- package/dist/page.js +30 -12
- package/dist/stub.d.ts +7 -2
- package/dist/stub.js +66 -25
- package/dist/twin.d.ts +52 -0
- package/dist/twin.js +1074 -0
- package/package.json +2 -2
- package/unity/KeepAcrossScenes.cs +9 -2
- package/unity/PORTING.md +100 -52
- package/unity/SceNoCoImporter.cs +334 -883
- package/unity/SceNoCoValidate.cs +96 -0
- package/unity/SplineKnotNodes.cs +66 -0
- package/unity/SplineMesh.cs +255 -0
- package/unity/Driver/SceNoCo.Driver.asmdef +0 -32
- package/unity/Driver/SceNoCoDriver.cs +0 -697
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
|
|
6
|
-
*
|
|
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(
|
|
49
|
-
|
|
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,12 @@ 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;
|
|
84
86
|
/** Its Unity layer, from a collider's `layer`: SceNoCo's layer n is Unity's user layer n + 7. */
|
|
85
87
|
layer?: number;
|
|
88
|
+
/** A placed model's objects that hold a mesh, as paths of names from its root, as glTFast names them. */
|
|
89
|
+
meshNodes?: string[][];
|
|
86
90
|
children: UnityNode[];
|
|
87
91
|
source?: string;
|
|
88
92
|
}
|
|
@@ -91,6 +95,8 @@ export interface UnityMesh {
|
|
|
91
95
|
vertices: number[];
|
|
92
96
|
normals?: number[];
|
|
93
97
|
uv?: number[];
|
|
98
|
+
/** Vertex colours, RGBA, linear: a material with `vertexColors` draws them. */
|
|
99
|
+
colors?: number[];
|
|
94
100
|
/** One triangle list per submesh, wound for Unity. */
|
|
95
101
|
submeshes: number[][];
|
|
96
102
|
}
|
|
@@ -113,6 +119,8 @@ export interface UnityMaterial {
|
|
|
113
119
|
emissionTexture?: string;
|
|
114
120
|
/** How often the textures repeat: three's `texture.repeat`, Unity's tiling. */
|
|
115
121
|
tiling?: number[];
|
|
122
|
+
/** Multiplied by the mesh's vertex colours: URP's Particles shaders, which Lit and Unlit are not. */
|
|
123
|
+
vertexColors?: boolean;
|
|
116
124
|
}
|
|
117
125
|
/**
|
|
118
126
|
* A terrain as Unity's `TerrainData` wants it. SceNoCo's is centred on its node with heights in
|
|
@@ -132,10 +140,13 @@ export interface UnityTerrain {
|
|
|
132
140
|
alphamapResolution: number;
|
|
133
141
|
/** 0..1, `alphamaps[(y * a + x) * layers + layer]`. */
|
|
134
142
|
alphamaps: number[];
|
|
143
|
+
/** Each layer's colour, and its textures' asset paths once the exporter copied them in. */
|
|
135
144
|
layers: {
|
|
136
145
|
name: string;
|
|
137
146
|
tileSize: number;
|
|
138
147
|
color: string;
|
|
148
|
+
texture?: string;
|
|
149
|
+
normalMap?: string;
|
|
139
150
|
}[];
|
|
140
151
|
}
|
|
141
152
|
export interface UnityPrefab {
|
|
@@ -185,6 +196,18 @@ export interface UnityExport {
|
|
|
185
196
|
};
|
|
186
197
|
/** The project-wide input actions asset. */
|
|
187
198
|
input?: string;
|
|
199
|
+
/**
|
|
200
|
+
* A model whose copies differ from Unity's defaults (`sharedModel(url, { castShadow: false })`), as a
|
|
201
|
+
* prefab variant of its file with its renderers set: what its placements and fields name instead.
|
|
202
|
+
*/
|
|
203
|
+
modelVariants: {
|
|
204
|
+
path: string;
|
|
205
|
+
model: string;
|
|
206
|
+
castShadow: boolean;
|
|
207
|
+
receiveShadow: boolean;
|
|
208
|
+
}[];
|
|
209
|
+
/** Images a behaviour's field holds — read as data, a height stamp — imported pixel for pixel. */
|
|
210
|
+
dataTextures: string[];
|
|
188
211
|
warnings: string[];
|
|
189
212
|
}
|
|
190
213
|
/** 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 +238,21 @@ export interface ConvertOptions {
|
|
|
215
238
|
ignore2D: [number, number][];
|
|
216
239
|
ignore3D: [number, number][];
|
|
217
240
|
};
|
|
241
|
+
/** Every type alias the game declares, by name: what a stub's signature that names one means. */
|
|
242
|
+
aliases?: Map<string, string>;
|
|
243
|
+
/** The page's `<template>`s as UXML, by id: `chip` → `Assets/UI/chip.uxml`. */
|
|
244
|
+
templates?: Record<string, string>;
|
|
245
|
+
/** Files the game loads that no field may name — a table of sounds — copied in all the same. */
|
|
246
|
+
files?: {
|
|
247
|
+
url: string;
|
|
248
|
+
type: string;
|
|
249
|
+
}[];
|
|
218
250
|
}
|
|
219
251
|
export declare function convert(snap: Snapshot, options?: ConvertOptions): Converted;
|
|
252
|
+
/** The C# type of an asset, by its file: a model imports as a GameObject, as a prefab does. */
|
|
253
|
+
export declare function assetType(path: string): string;
|
|
254
|
+
/**
|
|
255
|
+
* The objects of a .glb that hold a mesh, as glTFast builds them under the model's root: one per node
|
|
256
|
+
* of its scene, named as the node is, or `Node-<index>` when it has no name.
|
|
257
|
+
*/
|
|
258
|
+
export declare function glbMeshNodes(file: string): string[][];
|