0
votes

I am new to three.js(10 days) and I'm trying to replicate this codepen project:

https://codepen.io/zadvorsky/pen/PNXbGo

but I get this error :

script.js:140 Uncaught TypeError: Cannot read property 'ModelBufferGeometry' of undefined

                  function SlideGeometry(model) {
                    THREE.BAS.ModelBuffergeometry.call(this, model);
                  }

                  SlideGeometry.prototype = Object.create(THREE.BAS.ModelBufferGeometry.prototype); 
                  SlideGeometry.prototype.constructor = SlideGeometry;
                  SlideGeometry.prototype.bufferPositions = function() {
                  var positionBuffer = this.createAttribute('position', 3).array;

                  for (var i = 0; i < this.faceCount; i++) {
                     var face = this.ModelGeometry.faces[i];
                     var centroid = THREE.BAS.Utils.computeCentroid(this.modelGeometry, face);

                     var a = this.modelgeometry.vertices[faces.a];
                     var b = this.modelgeometry.vertices[faces.b];
                     var c = this.modelgeometry.vertices[faces.c];


                    positionBuffer[face.a * 3] = a.x - centroid.x;
                    positionBuffer[face.a * 3 + 1] = a.y - centroid.y;
                    positionBuffer[face.a * 3 + 2] = a.z - centroid.z;

                    positionBuffer[face.b * 3] = b.x - centroid.x;
                    positionBuffer[face.b * 3 + 1] = b.y - centroid.y;
                    positionBuffer[face.b * 3 + 2] = b.z - centroid.z;

                    positionBuffer[face.c * 3] = c.x - centroid.x;
                    positionBuffer[face.c * 3 + 1] = c.y - centroid.y;
                    positionBuffer[face.c * 3 + 2] = c.z - centroid.z;
                    }
                   };

what am I doing wrong? Can someone explain me?

ps: this is my codepen:

https://codepen.io/MedicM91/pen/LYEPErG

1
You should simply load missing js... Take a look at zadvorsky pen settings - soju
I've done it but I keep getting the same mistake - MarioM91
You didn't, your pen's js settings are empty - soju

1 Answers

-1
votes

you just need this scripts in your html

    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r79/three.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/TweenMax.min.js"></script>
    <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/175711/bas.js"></script>
    <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/175711/OrbitControls-2.js"></script>