xeokit / xeokit-convert

Convert various AEC model formats for efficient viewing in the browser with xeokit.

Home Page:https://xeokit.github.io/xeokit-convert/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ERROR]: [parseGLTFIntoXKTModel] RangeError: Invalid typed array length

kushal154 opened this issue · comments

I am getting the following getting issue while converting split gltf files into xkt format using v1.1.15-beta-7 version.

% node --no-experimental-fetch convert2xkt.js -a final.manifest.json -o finalxkt -l
[convert2xkt] Running convert2xkt v1.1.15-beta-7...
[convert2xkt] Using configs in ./convert2xkt.conf.js
[convert2xkt] Converting glTF files in manifest final.manifest.json...
[convert2xkt] Reading input file: final.gltf
[convert2xkt] Input file size: 22873.48 kB
[convert2xkt] Not embedding metadata in XKT
(node:98135) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[convert2xkt] [ERROR]: [parseGLTFIntoXKTModel] RangeError: Invalid typed array length: 8098752

Here is the content of final.manifest.json file

{
    "inputFile": "final.ifc",
    "converterApplication": "ifc2gltfcxconverter",
    "converterApplicationVersion": "3.0.25",
    "conversionDate": "2024-04-05 16:56:49",
    "gltfOutFiles": [
        "final.gltf",
        "final_1.gltf",
        "final_2.gltf",
        "final_3.gltf",
        "final_4.gltf",
        "final_5.gltf",
        "final_6.gltf"
    ],
    "metadataOutFiles": [
        "final.json",
        "final_1.json"
    ],
    "numCreatedGltfMeshes": 461618,
    "numCreatedMetaObjects": 147507,
    "numExportedPropertySetsOrElementQuantities": 0,
    "modelBoundsMax": [
        287.4798129720813,
        -43.44965391434808,
        685.1595312500016
    ],
    "modelBoundsMin": [
        209.76544292448088,
        -110.21504245524804,
        654.6
    ]
}

What could be the issue?

Sometimes NodeJS (that convert2xkt runs on) runs out of memory when processing large glTF files, especially if they have geometry and textures embedded inline.

For optimal results, Try converting .glb files instead, with geometry as external binary attachments (ie. not embedded into the glTF JSON).

Also you could try just ensuring that the geometry buffers are external .bin files. But .glb is always best.

This is due to NodeJS having a maximum string limit of 1GB, where a whole glTF with embedded geometry/textures tends to overrun that when files are big enough.

@xeolabs Kindly let me know the way to do that. I used the following command:

Ifc2gltfcxconverter.exe -i “final.ifc” -o “final.gltf” -m “final.metadata.json” -s 20

It created following files:

-rw-r--r--@ 1 kushal  staff    17M Apr  8 10:35 final.bin
-rw-r--r--@ 1 kushal  staff    22M Apr  8 10:35 final.gltf
-rw-r--r--@ 1 kushal  staff    20M Apr  8 10:35 final.json
-rw-r--r--@ 1 kushal  staff   816B Apr  8 10:35 final.manifest.json
-rw-r--r--@ 1 kushal  staff    19M Apr  8 10:35 final_1.bin
-rw-r--r--@ 1 kushal  staff    18M Apr  8 10:35 final_1.gltf
-rw-r--r--@ 1 kushal  staff   1.4M Apr  8 10:35 final_1.json
-rw-r--r--@ 1 kushal  staff    19M Apr  8 10:35 final_2.bin
-rw-r--r--@ 1 kushal  staff    20M Apr  8 10:35 final_2.gltf
-rw-r--r--@ 1 kushal  staff    19M Apr  8 10:35 final_3.bin
-rw-r--r--@ 1 kushal  staff    11M Apr  8 10:35 final_3.gltf
-rw-r--r--@ 1 kushal  staff    18M Apr  8 10:35 final_4.bin
-rw-r--r--@ 1 kushal  staff    21M Apr  8 10:35 final_4.gltf
-rw-r--r--@ 1 kushal  staff    19M Apr  8 10:35 final_5.bin
-rw-r--r--@ 1 kushal  staff    21M Apr  8 10:35 final_5.gltf
-rw-r--r--@ 1 kushal  staff    12M Apr  8 10:35 final_6.bin
-rw-r--r--@ 1 kushal  staff    13M Apr  8 10:35 final_6.gltf

What change would you have me make while executing Ifc2gltfcxconverter?

Try this:

Ifc2gltfcxconverter.exe -i “final.ifc” -o “final.glb” -m “final.metadata.json” -s 20

Note that I renamed "final.gltf" to "final.glb", which causes the converter to output .glb files.

In case it's useful, a reference for how to use on Linux, which is similar to how it's used on Windows:

https://xeokit.github.io/xeokit-model-conversion-tests/ifc-tests.html

@xeolabs Thanks for your prompt response. The final thing on the Linux command. I am getting the following error on the Macbook as well as the AWS instance. Would you know what is this about?

bash-5.2$ ./ifc2gltfcxconverter -i final.ifc -o final.glb -m final.metadata.json -s 20
./ifc2gltfcxconverter: ./ifc2gltfcxconverter: cannot execute binary file

Possibly the architecture is not compatible with the binary? That would explain the Mac issue (I've never tested on Mac)

https://superuser.com/questions/435988/how-can-i-resolve-the-error-cannot-execute-binary-file

Note that I'm using Ubuntu - see if you can ruin that on AWS.