C.value undefined error on rhino3dm.js

whats the difference between this two files?

test_ok.3dm (285.3 KB)
test_error.3dm (295.2 KB)

the “test_ok” was created in rhino6 and than opened and modified in rhino7
the “test_error” was created in rhino7

“test_ok” is loaded with rhino3dm.js and rhino3dm.wasm (version 14.0) without problems but the “test_error” give me this error:

TypeError: Cannot read property 'value' of undefined

in this function

    function __embind_register_enum(rawType, name, size, isSigned) {
        var shift = getShiftFromSize(size);
        name = readLatin1String(name);
        function ctor() {}
        ctor.values = {};
        registerType(rawType, {
            name: name,
            constructor: ctor,
            "fromWireType": function(c) {
                return this.constructor.values[c]
            },
            "toWireType": function(destructors, c) {
                return c.value
            },
            "argPackAdvance": 8,
            "readValueFromPointer": enumReadValueFromPointer(name, shift, isSigned),
            destructorFunction: null
        });
        exposePublicSymbol(name, ctor)

on the code “toWireType” the destructors are an empty list and c is undefinded

edit: if i changed the rendermode to “raytrace” and back to “shaded” bevor saving the “test_error” is working too. Why is this?

@fraguada - is this something you can help with?

I’ve been looking into this but don’t have a conclusion yet. It seems to have to do with materials and textures, specifically related to Rhino 7’s PBR materials. You can solve this for the moment by running _Purge on the model to purge anything that is unnecessary. When I do this, the model loads fine. I’ve attached this model. I am also going to add some error catching around the suspect code to catch this but allow the model to continue loading. This will be available in a future version of the Rhino3dmLoader.js library for three.js.

test_error_purge.3dm (3.7 MB)

Thanks for the information. Since i normally generate the needed files via dotnet and rhinocommen: Whats the equal command for purge in rhinocommen?

Apologies. You need not do anything. I found the error in my code which was related to checking texture types between materials. I believe in your case it came up because your materials are compatible with pbrMaterials (because the model was passed through Rhino 7) and thus the code checks against that, and there was an error in that code. I will make a PR to the main threejs repo (r129 to be released May 26th), but if you need this before, you can get the fixed file from our fork: three.js/3DMLoader.js at wip/3DMLoader · mcneel/three.js · GitHub