未捕获的TypeError:无法读取未定义的属性'ModelBufferGeometry'

时间:2019-11-29 11:08:11

标签: javascript three.js

我是three.js(10天)的新手,我正在尝试复制此Codepen项目:

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

但是我得到这个错误:

script.js:140未捕获的TypeError:无法读取未定义的属性'ModelBufferGeometry'

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

我在做什么错?有人可以解释我吗?

ps:这是我的codepen:

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

1 个答案:

答案 0 :(得分:-1)

你只需要在你的 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>