这是代码:
<html lang="en">
<head>
<meta charset="utf-8">
<script src="node_modules\aframe\dist\aframe.min.js" type="text/javascript"></script>
<script type:"text/javascript">
var sceneEl = document.querySelector('a-scene');
AFRAME.registerComponent('loadchunk', {
init: function () {console.log('loadChunk initialized');
}
});
function loadChunk (ndx){
var passId = "zChunk" + ndx;
var zPos = ndx * 12;
var addEl = document.createElement('a-entity');
addEl.setAttribute("gltf-model", "#bound");
addEl.object3D.position.set(0, 0, zPos);
sceneEl.appendChild(addEl);
}
function initLoad (){
var i;
for(i=-13; i<12; i++){
loadChunk(i);
}
}
</script>
</head>
<body>
<a-scene>
<a-assets>
<a-asset-item id="bound" src="/models/boundery.gltf" ></a-asset-item>
</a-assets>
<a-sky color="#ECECEC"></a-sky>
</a-scene>
<script type="text/javascript">
initLoad();
</script>
</body>
</html>
这是错误:
(index):18 Uncaught TypeError: Cannot read property 'appendChild' of null at loadChunk ((index):18) at initLoad ((index):24) at (index):38 loadChunk @ (index):18 initLoad @ (索引):24(匿名)@(索引):38
不知道我不知道什么。:P