@stowkit/three-loader 0.1.21 → 0.1.23
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 +34 -0
- package/dist/MeshParser.d.ts.map +1 -1
- package/dist/StowKitLoader.d.ts +1 -1
- package/dist/StowKitLoader.d.ts.map +1 -1
- package/dist/stowkit-three-loader.esm.js +16 -25
- package/dist/stowkit-three-loader.esm.js.map +1 -1
- package/dist/stowkit-three-loader.js +16 -25
- package/dist/stowkit-three-loader.js.map +1 -1
- package/package.json +1 -1
|
@@ -143,18 +143,14 @@ class MeshParser {
|
|
|
143
143
|
}
|
|
144
144
|
// Parse mesh indices
|
|
145
145
|
const totalMeshRefs = nodes.reduce((sum, node) => sum + node.meshCount, 0);
|
|
146
|
-
console.log(`Parsing ${totalMeshRefs} mesh indices at offset ${offset}`);
|
|
147
146
|
const meshIndices = new Uint32Array(totalMeshRefs);
|
|
148
147
|
for (let i = 0; i < totalMeshRefs; i++) {
|
|
149
148
|
if (offset + (i + 1) * 4 > sourceBlob.length) {
|
|
150
|
-
console.warn(`Data truncated at mesh index ${i}/${totalMeshRefs}`);
|
|
151
149
|
break;
|
|
152
150
|
}
|
|
153
151
|
meshIndices[i] = metaView.getUint32(offset + i * 4, true);
|
|
154
|
-
console.log(` meshIndices[${i}] = ${meshIndices[i]}`);
|
|
155
152
|
}
|
|
156
153
|
offset += totalMeshRefs * 4;
|
|
157
|
-
console.log(`After mesh indices, offset = ${offset}`);
|
|
158
154
|
// Second pass: read material properties
|
|
159
155
|
// MaterialPropertyValue: field_name[64] + value[4*4=16] + texture_id[64] = 144 bytes
|
|
160
156
|
for (let i = 0; i < materialData.length; i++) {
|
|
@@ -233,7 +229,6 @@ class MeshParser {
|
|
|
233
229
|
resolve(decoded);
|
|
234
230
|
}, undefined, (error) => {
|
|
235
231
|
URL.revokeObjectURL(url);
|
|
236
|
-
console.error('Draco decode failed:', error);
|
|
237
232
|
reject(new Error(`Failed to decode Draco geometry: ${error}`));
|
|
238
233
|
});
|
|
239
234
|
});
|
|
@@ -271,7 +266,6 @@ class MeshParser {
|
|
|
271
266
|
material = materials[geoInfo.materialIndex];
|
|
272
267
|
}
|
|
273
268
|
else {
|
|
274
|
-
console.warn(` Material index ${geoInfo.materialIndex} out of bounds, using default`);
|
|
275
269
|
material = new THREE__namespace.MeshStandardMaterial({
|
|
276
270
|
color: new THREE__namespace.Color(0.8, 0.8, 0.8),
|
|
277
271
|
roughness: 0.5,
|
|
@@ -282,9 +276,6 @@ class MeshParser {
|
|
|
282
276
|
const mesh = new THREE__namespace.Mesh(geometry, material);
|
|
283
277
|
obj.add(mesh);
|
|
284
278
|
}
|
|
285
|
-
else {
|
|
286
|
-
console.error(`Mesh index ${meshIndex} out of bounds (${geometries.length} geometries available)`);
|
|
287
|
-
}
|
|
288
279
|
}
|
|
289
280
|
nodeObjects.push(obj);
|
|
290
281
|
}
|
|
@@ -310,7 +301,6 @@ class MeshParser {
|
|
|
310
301
|
material = materials[geoInfo.materialIndex];
|
|
311
302
|
}
|
|
312
303
|
else {
|
|
313
|
-
console.warn(` Material index ${geoInfo.materialIndex} out of bounds, using default`);
|
|
314
304
|
material = new THREE__namespace.MeshStandardMaterial({
|
|
315
305
|
color: new THREE__namespace.Color(0.8, 0.8, 0.8),
|
|
316
306
|
roughness: 0.5,
|
|
@@ -1083,10 +1073,12 @@ class StowKitLoader {
|
|
|
1083
1073
|
throw new Error(`Failed to fetch ${url}: ${response.statusText}`);
|
|
1084
1074
|
}
|
|
1085
1075
|
const arrayBuffer = await response.arrayBuffer();
|
|
1086
|
-
//
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1076
|
+
// Create a new reader instance for this pack
|
|
1077
|
+
const reader$1 = new reader.StowKitReader(this.wasmPath);
|
|
1078
|
+
await reader$1.init();
|
|
1079
|
+
await reader$1.open(arrayBuffer);
|
|
1080
|
+
// Return pack wrapper with its own dedicated reader
|
|
1081
|
+
return new StowKitPack(reader$1, this.ktx2Loader, this.dracoLoader);
|
|
1090
1082
|
}
|
|
1091
1083
|
/**
|
|
1092
1084
|
* Load a .stow pack from memory (ArrayBuffer, Blob, or File)
|
|
@@ -1110,25 +1102,24 @@ class StowKitLoader {
|
|
|
1110
1102
|
else {
|
|
1111
1103
|
throw new Error('Data must be ArrayBuffer, Blob, or File');
|
|
1112
1104
|
}
|
|
1113
|
-
//
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1105
|
+
// Create a new reader instance for this pack
|
|
1106
|
+
const reader$1 = new reader.StowKitReader(this.wasmPath);
|
|
1107
|
+
await reader$1.init();
|
|
1108
|
+
await reader$1.open(arrayBuffer);
|
|
1109
|
+
// Return pack wrapper with its own dedicated reader
|
|
1110
|
+
return new StowKitPack(reader$1, this.ktx2Loader, this.dracoLoader);
|
|
1117
1111
|
}
|
|
1118
1112
|
/**
|
|
1119
1113
|
* Initialize the loader (called automatically on first load)
|
|
1120
1114
|
*/
|
|
1121
1115
|
static async initialize(options) {
|
|
1122
|
-
|
|
1116
|
+
this.wasmPath = options?.wasmPath || '/stowkit/stowkit_reader.wasm';
|
|
1123
1117
|
const basisPath = options?.basisPath || '/stowkit/basis/';
|
|
1124
1118
|
const dracoPath = options?.dracoPath || '/stowkit/draco/';
|
|
1125
|
-
//
|
|
1126
|
-
this.reader = new reader.StowKitReader(wasmPath);
|
|
1127
|
-
await this.reader.init();
|
|
1128
|
-
// Setup KTX2 loader
|
|
1119
|
+
// Setup KTX2 loader (shared across all packs)
|
|
1129
1120
|
this.ktx2Loader = new KTX2Loader_js.KTX2Loader();
|
|
1130
1121
|
this.ktx2Loader.setTranscoderPath(basisPath);
|
|
1131
|
-
// Setup Draco loader
|
|
1122
|
+
// Setup Draco loader (shared across all packs)
|
|
1132
1123
|
this.dracoLoader = new DRACOLoader_js.DRACOLoader();
|
|
1133
1124
|
this.dracoLoader.setDecoderPath(dracoPath);
|
|
1134
1125
|
// Detect support
|
|
@@ -1138,10 +1129,10 @@ class StowKitLoader {
|
|
|
1138
1129
|
this.initialized = true;
|
|
1139
1130
|
}
|
|
1140
1131
|
}
|
|
1141
|
-
StowKitLoader.reader = null;
|
|
1142
1132
|
StowKitLoader.ktx2Loader = null;
|
|
1143
1133
|
StowKitLoader.dracoLoader = null;
|
|
1144
1134
|
StowKitLoader.initialized = false;
|
|
1135
|
+
StowKitLoader.wasmPath = '/stowkit/stowkit_reader.wasm';
|
|
1145
1136
|
|
|
1146
1137
|
Object.defineProperty(exports, 'AssetType', {
|
|
1147
1138
|
enumerable: true,
|