mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.69k stars 35.37k forks source link

TypeError: geometry.computeCentroids is not a function #5368

Closed pl1307 closed 10 years ago

pl1307 commented 10 years ago

I wanted to load this file with VRMLLoader:

#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
}

Watching this file works in cortona3d if you click on "fit" because the camera position is strange. I have the same error in multiple files, but I have choosen this file because it is the smallest one.

WestLangley commented 10 years ago

The method geometry.computeCentroids() was removed in r.67. Are you calling it in your application? Are your include files from the same release version as the three.js library you are linking to?

pl1307 commented 10 years ago

I dont't know. I didn't found the VRMLLoader in this repository, then I took the VRMLLoader.js from this example: http://bdcampbell.net/book/software/vplayground/vrml_example.html Most likely it is a older version. I have solved my problem with a collada import which works great. Thanks for your help!

WestLangley commented 10 years ago

You can find the loader compatible with the current release here: http://github.com/mrdoob/three.js/tree/master/examples/js/loaders

jasonworden commented 8 years ago

I got a very similar error:

Your program encountered an unrecoverable error, can not draw on canvas. Error was:

TypeError: this.computeCentroids is not a function

when declaring

var eyeGeom = THREE.SphereGeometry(10, 32, 16);

without the new as it should be like so:

var eyeGeom = new THREE.SphereGeometry(10, 32, 16);

Perhaps this helps you.