circuit-json-to-gltf 0.0.153 → 0.0.154
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/index.js +44 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17285,36 +17285,51 @@ function getAccessorData(accessor, bufferViews, binaryBuffer) {
|
|
|
17285
17285
|
const type = accessor.type;
|
|
17286
17286
|
const componentsPerElement = type === "SCALAR" ? 1 : type === "VEC2" ? 2 : type === "VEC3" ? 3 : type === "VEC4" ? 4 : 1;
|
|
17287
17287
|
const totalComponents = count * componentsPerElement;
|
|
17288
|
-
|
|
17288
|
+
const componentSize = componentType === 5120 || componentType === 5121 ? 1 : componentType === 5122 || componentType === 5123 ? 2 : 4;
|
|
17289
|
+
const elementSize = componentSize * componentsPerElement;
|
|
17290
|
+
const stride = bufferView.byteStride ?? elementSize;
|
|
17291
|
+
if (componentType === 5126 && stride === elementSize) {
|
|
17289
17292
|
return new Float32Array(binaryBuffer, byteOffset, totalComponents);
|
|
17290
|
-
}
|
|
17291
|
-
|
|
17292
|
-
|
|
17293
|
-
|
|
17294
|
-
|
|
17295
|
-
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
|
|
17301
|
-
|
|
17302
|
-
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
-
|
|
17306
|
-
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
|
|
17310
|
-
|
|
17311
|
-
|
|
17312
|
-
|
|
17313
|
-
|
|
17314
|
-
|
|
17315
|
-
|
|
17316
|
-
|
|
17317
|
-
|
|
17293
|
+
}
|
|
17294
|
+
const view = new DataView(binaryBuffer);
|
|
17295
|
+
const result = new Float32Array(totalComponents);
|
|
17296
|
+
for (let element = 0; element < count; element++) {
|
|
17297
|
+
for (let component = 0; component < componentsPerElement; component++) {
|
|
17298
|
+
const offset = byteOffset + element * stride + component * componentSize;
|
|
17299
|
+
let value;
|
|
17300
|
+
switch (componentType) {
|
|
17301
|
+
case 5120:
|
|
17302
|
+
value = view.getInt8(offset);
|
|
17303
|
+
if (accessor.normalized) value = Math.max(value / 127, -1);
|
|
17304
|
+
break;
|
|
17305
|
+
case 5121:
|
|
17306
|
+
value = view.getUint8(offset);
|
|
17307
|
+
if (accessor.normalized) value /= 255;
|
|
17308
|
+
break;
|
|
17309
|
+
case 5122:
|
|
17310
|
+
value = view.getInt16(offset, true);
|
|
17311
|
+
if (accessor.normalized) value = Math.max(value / 32767, -1);
|
|
17312
|
+
break;
|
|
17313
|
+
case 5123:
|
|
17314
|
+
value = view.getUint16(offset, true);
|
|
17315
|
+
if (accessor.normalized) value /= 65535;
|
|
17316
|
+
break;
|
|
17317
|
+
case 5124:
|
|
17318
|
+
value = view.getInt32(offset, true);
|
|
17319
|
+
break;
|
|
17320
|
+
case 5125:
|
|
17321
|
+
value = view.getUint32(offset, true);
|
|
17322
|
+
break;
|
|
17323
|
+
case 5126:
|
|
17324
|
+
value = view.getFloat32(offset, true);
|
|
17325
|
+
break;
|
|
17326
|
+
default:
|
|
17327
|
+
throw new Error(`Unsupported component type: ${componentType}`);
|
|
17328
|
+
}
|
|
17329
|
+
result[element * componentsPerElement + component] = value;
|
|
17330
|
+
}
|
|
17331
|
+
}
|
|
17332
|
+
return result;
|
|
17318
17333
|
}
|
|
17319
17334
|
function computeNormal(v0, v1, v2) {
|
|
17320
17335
|
const edge1 = {
|