MCPcopy Create free account
hub / github.com/esengine/esengine / readNode

Function readNode

scripts/analyze-fbx.mjs:27–139  ·  view source on GitHub ↗
(is64Bit)

Source from the content-addressed store, hash-verified

25let offset = 27; // After header
26
27function readNode(is64Bit) {
28 const startOffset = offset;
29
30 let endOffset, numProperties, propertyListLen, nameLen;
31 if (is64Bit) {
32 endOffset = Number(view.getBigUint64(offset, true));
33 numProperties = Number(view.getBigUint64(offset + 8, true));
34 propertyListLen = Number(view.getBigUint64(offset + 16, true));
35 nameLen = view.getUint8(offset + 24);
36 offset += 25;
37 } else {
38 endOffset = view.getUint32(offset, true);
39 numProperties = view.getUint32(offset + 4, true);
40 propertyListLen = view.getUint32(offset + 8, true);
41 nameLen = view.getUint8(offset + 12);
42 offset += 13;
43 }
44
45 if (endOffset === 0) return null;
46
47 const name = new TextDecoder().decode(buffer.slice(offset, offset + nameLen));
48 offset += nameLen;
49
50 // Read properties
51 const properties = [];
52 const propsEnd = offset + propertyListLen;
53
54 while (offset < propsEnd) {
55 const typeCode = String.fromCharCode(buffer[offset]);
56 offset++;
57
58 switch (typeCode) {
59 case 'Y': // Int16
60 properties.push(view.getInt16(offset, true));
61 offset += 2;
62 break;
63 case 'C': // Bool
64 properties.push(buffer[offset] !== 0);
65 offset += 1;
66 break;
67 case 'I': // Int32
68 properties.push(view.getInt32(offset, true));
69 offset += 4;
70 break;
71 case 'F': // Float
72 properties.push(view.getFloat32(offset, true));
73 offset += 4;
74 break;
75 case 'D': // Double
76 properties.push(view.getFloat64(offset, true));
77 offset += 8;
78 break;
79 case 'L': // Int64
80 properties.push(view.getBigInt64(offset, true));
81 offset += 8;
82 break;
83 case 'S': // String
84 case 'R': // Raw binary

Callers 1

analyze-fbx.mjsFile · 0.70

Calls 9

getUint8Method · 0.80
getUint32Method · 0.80
getInt16Method · 0.80
getInt32Method · 0.80
getFloat32Method · 0.80
getFloat64Method · 0.80
pushMethod · 0.65
decodeMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected