我正在使用three.js,当我将相机添加到场景时,它会警告错误
Object doesn't support property or method 'indexOf'
我的代码是
<script src="build/Three.js"></script>
<script>
var container;
var camera, scene, renderer, objects;
var particleLight, pointLight,theta = 45;
var materials,k=0;
init();
animate();
function init()
{
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.set( 0, 200, 800 );
scene = new THREE.Scene();
scene.add(camera);
}
</script>
在 Three.js 文件中使用 indexOf 函数,代码如下
add:function(a){if(a===this)console.warn("THREE.Object3D.add: An object can't be added as a child of itself.");else if(-1===this.children.indexOf(a)){void 0!==a.parent&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__addObject(a)}}