create-threejs-game 1.1.1 → 1.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-threejs-game",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Scaffold a Three.js game project with AI-assisted design documents",
5
5
  "bin": {
6
6
  "create-threejs-game": "./bin/cli.js"
@@ -63,8 +63,17 @@ function getCategory(ext) {
63
63
  return 'Other';
64
64
  }
65
65
 
66
+ // Get pack name from relative path (first directory component)
67
+ function getPackName(relativePath) {
68
+ const parts = relativePath.split('/');
69
+ if (parts.length > 1) {
70
+ return parts[0];
71
+ }
72
+ return null; // Asset is at root level
73
+ }
74
+
66
75
  // Recursively scan directory for assets
67
- function scanDirectory(dir, relativeTo) {
76
+ function scanDirectory(dir, relativeTo, rootDir = relativeTo) {
68
77
  const assets = [];
69
78
 
70
79
  if (!fs.existsSync(dir)) {
@@ -77,8 +86,10 @@ function scanDirectory(dir, relativeTo) {
77
86
  const fullPath = path.join(dir, item.name);
78
87
 
79
88
  if (item.isDirectory()) {
89
+ // Skip hidden directories
90
+ if (item.name.startsWith('.')) continue;
80
91
  // Recursively scan subdirectories
81
- assets.push(...scanDirectory(fullPath, relativeTo));
92
+ assets.push(...scanDirectory(fullPath, relativeTo, rootDir));
82
93
  } else if (item.isFile()) {
83
94
  const ext = path.extname(item.name).toLowerCase();
84
95
 
@@ -93,17 +104,25 @@ function scanDirectory(dir, relativeTo) {
93
104
 
94
105
  if (!allExtensions.includes(ext)) continue;
95
106
 
96
- const relativePath = path.relative(relativeTo, fullPath);
107
+ const relativePath = path.relative(relativeTo, fullPath).replace(/\\/g, '/');
97
108
  const category = getCategory(ext);
109
+ const pack = getPackName(relativePath);
98
110
 
99
- assets.push({
111
+ const asset = {
100
112
  name: item.name,
101
- path: `public/assets/${gameName}/${relativePath.replace(/\\/g, '/')}`,
102
- relativePath: relativePath.replace(/\\/g, '/'),
113
+ path: `public/assets/${gameName}/${relativePath}`,
114
+ relativePath: relativePath,
103
115
  category: category,
104
116
  extension: ext,
105
117
  focusGlTF: ext === '.gltf' || ext === '.glb'
106
- });
118
+ };
119
+
120
+ // Add pack field if asset is in a subdirectory
121
+ if (pack) {
122
+ asset.pack = pack;
123
+ }
124
+
125
+ assets.push(asset);
107
126
  }
108
127
  }
109
128
 
@@ -115,8 +134,18 @@ console.log(`Scanning assets in: ${assetsDir}`);
115
134
 
116
135
  const assets = scanDirectory(assetsDir, assetsDir);
117
136
 
118
- // Sort assets by name
119
- assets.sort((a, b) => a.name.localeCompare(b.name));
137
+ // Sort assets by pack then name
138
+ assets.sort((a, b) => {
139
+ if (a.pack && b.pack) {
140
+ const packCompare = a.pack.localeCompare(b.pack);
141
+ if (packCompare !== 0) return packCompare;
142
+ } else if (a.pack) {
143
+ return 1; // Assets with packs after root assets
144
+ } else if (b.pack) {
145
+ return -1;
146
+ }
147
+ return a.name.localeCompare(b.name);
148
+ });
120
149
 
121
150
  // Count by category
122
151
  const categoryCounts = {};
@@ -124,9 +153,19 @@ for (const asset of assets) {
124
153
  categoryCounts[asset.category] = (categoryCounts[asset.category] || 0) + 1;
125
154
  }
126
155
 
156
+ // Count by pack
157
+ const packCounts = {};
158
+ for (const asset of assets) {
159
+ const pack = asset.pack || '(root)';
160
+ packCounts[pack] = (packCounts[pack] || 0) + 1;
161
+ }
162
+
127
163
  // Count glTF assets
128
164
  const glTFCount = assets.filter(a => a.focusGlTF).length;
129
165
 
166
+ // Get unique packs
167
+ const packs = [...new Set(assets.map(a => a.pack).filter(Boolean))];
168
+
130
169
  // Build output
131
170
  const output = {
132
171
  metadata: {
@@ -134,7 +173,9 @@ const output = {
134
173
  root: `public/assets/${gameName}`,
135
174
  totalAssets: assets.length,
136
175
  glTFAssetCount: glTFCount,
137
- categories: categoryCounts
176
+ categories: categoryCounts,
177
+ packs: packs.length > 0 ? packs : undefined,
178
+ packCounts: packs.length > 0 ? packCounts : undefined
138
179
  },
139
180
  assets: assets
140
181
  };
@@ -147,3 +188,6 @@ console.log(`\nSummary:`);
147
188
  console.log(` Total assets: ${assets.length}`);
148
189
  console.log(` glTF/GLB models: ${glTFCount}`);
149
190
  console.log(` Categories:`, categoryCounts);
191
+ if (packs.length > 0) {
192
+ console.log(` Packs (${packs.length}):`, packCounts);
193
+ }