1

I'm trying to import a VRML file in three.js, but it doesn't work. Here is the VRML file:

#VRML V2.0 utf8

#Created by CINEMA 4D

DEF B1 Transform {
 translation 600 0 0.333333
 children [ 
 DEF _60_ Transform {
  translation -600 0 0
  children [ 
  ]
}
DEF Button Transform {
  translation 679.734143 0 0
  children [ 
    Shape {
      appearance DEF MAT_Metal_010 Appearance {
        material Material {
          ambientIntensity 0.2
          diffuseColor 0.815686 0 0.223529
          specularColor 0 0 0
          emissiveColor 0 0 0
          shininess 0.1
          transparency 0
        }
      }
      geometry DEF FACESET_Button IndexedFaceSet {
        ccw FALSE
        creaseAngle 1.396263
        coord Coordinate {
          point [ -100 -100 -100,-100 100 -100,-100 -100 100,-100 100 100,100 -100 100,
            100 100 100,100 -100 -100,100 100 -100
          ]
        }
        texCoord TextureCoordinate {
          point [ 0 1,1 0,
            0 0,0 0,1 1,0 1,1 1,
            0 0,1 0,1 0,0 1,1 1,
            1 0,0 0,1 1,0 1,0 0,
            1 0,0 1,1 1
          ]
        }
        coordIndex [ 0,1,3,2,-1,2,3,5,4,-1,4,5,7,6,-1,
          6,7,1,0,-1,1,7,5,3,-1,6,0,2,4,-1
        ]
        texCoordIndex [ 2,5,11,8,-1,7,10,14,12,-1,13,15,19,17,-1,
          16,18,4,1,-1,3,18,14,9,-1,16,0,6,12,-1
        ]
      }
    }
  ]
 }
]
}
DEF Timer TimeSensor {
startTime 0
stopTime 0
cycleInterval 14.4
loop TRUE
}

And here is my JavaScript code for the import:

var loader = new THREE.VRMLLoader();
loader.addEventListener( 'load', function ( event ) {
    scene.add(event.content);
    } );
loader.load( "models/MyVRML.wrl" );

The error message in the browser is:

TypeError: a is undefined three.js:1636.

I use the actual three.js (not minified)

Thanks for your help!

Echoes137
  • 55
  • 7

1 Answers1

1

For now, your points should each be on their own line. I am willing to fix this, but currently facing a tight deadline. The workaround for now is to setup the coordinates like so:

coord  Coordinate { #default NULL
    point [
        0.14    0   -0.14,
        5.54    0   -0.14,
        5.54    0   -8.86,
        0.14    0   -8.86,
    ]
}
Bart McLeod
  • 151
  • 2
  • 6
  • is the trailing comma optional? I have a VRML model that omits the last ocmma but renders fine with [X_ITE](http://create3000.de/x_ite/getting-started/#embedding-x-ite-within-a-web-page). – Dave Everitt Feb 02 '20 at 15:08
  • 1
    @DaveEveritt I would have to check if it is optional in the VRML specs. There are quite a few loose rules in the specs, so it wouldn't surprise me if they are optional. Did you experience it is not optional in vrmlparser, or put otherwise, can you provide a little more context to your question? Also, vrmlparser integrates with threejs, but the VrmlParser that ships with threejs is outdated. So your experience may differ based on what you are using. – Bart McLeod Feb 03 '20 at 17:07
  • I just noted that it didn’t seem to matter in the legacy VRML I’m dealing with, and I wondered about the exact soecs. In some languages (e.g. Python) IIRC it’s optional, but I couldn’t find an answer looking through the specs. Not a crucial issue! – Dave Everitt Feb 03 '20 at 19:46