# C.value undefined error on rhino3dm.js

**URL:** <https://discourse.mcneel.com/t/c-value-undefined-error-on-rhino3dm-js/122596>\
**Category:** rhino3dm\
**Tags:** javascript\
**Created:** [April 18, 2021, 9:07am UTC](https://discourse.mcneel.com/t/c-value-undefined-error-on-rhino3dm-js/122596 "2021-04-18T09:07:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![atelierkirchhof](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/atelierkirchhof/32/638937_2.png) [@atelierkirchhof](https://discourse.mcneel.com/u/atelierkirchhof)\
**Post date:** [April 18, 2021, 9:07am UTC](https://discourse.mcneel.com/t/c-value-undefined-error-on-rhino3dm-js/122596/1 "2021-04-18T09:07:20Z")

</div>

whats the difference between this two files?

[test\_ok.3dm](https://discourse.mcneel.com/uploads/short-url/pniXzXNmH3ZwndwjSi59S5czGZf.3dm) (285.3 KB)  
[test\_error.3dm](https://discourse.mcneel.com/uploads/short-url/srsOjBneamlbFxSeXR4UOwHmBBx.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?

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [April 27, 2021, 4:47pm UTC](https://discourse.mcneel.com/t/c-value-undefined-error-on-rhino3dm-js/122596/2 "2021-04-27T16:47:45Z")

</div>

@fraguada - is this something you can help with?

---

<div class="post-metadata">

**Author:** ![fraguada](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/fraguada/32/758439_2.png) [@fraguada](https://discourse.mcneel.com/u/fraguada)\
**Post date:** [April 30, 2021, 9:21am UTC](https://discourse.mcneel.com/t/c-value-undefined-error-on-rhino3dm-js/122596/3 "2021-04-30T09:21:09Z")

</div>

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](https://discourse.mcneel.com/uploads/short-url/fCr0TfYEOL5bziOHORfsysUAFY4.3dm) (3.7 MB)

---

<div class="post-metadata">

**Author:** ![atelierkirchhof](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/atelierkirchhof/32/638937_2.png) [@atelierkirchhof](https://discourse.mcneel.com/u/atelierkirchhof)\
**Post date:** [April 30, 2021, 9:34am UTC](https://discourse.mcneel.com/t/c-value-undefined-error-on-rhino3dm-js/122596/4 "2021-04-30T09:34:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fraguada](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/fraguada/32/758439_2.png) [@fraguada](https://discourse.mcneel.com/u/fraguada)\
**Post date:** [April 30, 2021, 10:12am UTC](https://discourse.mcneel.com/t/c-value-undefined-error-on-rhino3dm-js/122596/5 "2021-04-30T10:12:10Z")

</div>

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](https://github.com/mcneel/three.js/blob/wip/3DMLoader/examples/jsm/loaders/3DMLoader.js)
