Replit 上的 Three.js 库未显示在文档中
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(120, window.innerwidth / window.innerheight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerwidth, window.innerheight);
document.body.appendChild(renderer.domElement);
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({color: 0x000fff});
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
camera.position.z = 5;
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
我正在使用 Replit 来执行此操作,但是当我运行它时没有显示任何内容,并且没有错误消息。我已经尝试过 replit 上的人的其他代码,他们的代码工作得很好,但他们的代码几乎与我的相同,我也在我的项目中尝试了代码,它工作得很好。
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(120, window.innerwidth / window.innerheight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerwidth, window.innerheight);
document.body.appendChild(renderer.domElement);
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({color: 0x000fff});
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
camera.position.z = 5;
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
I am using Replit to do this but nothing is showing when i run it and there is no error message. I have tried other code from people on replit and theirs works fine but their code is almost identical to mine, I also tried there code in my project and it works fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两行都有错别字。应该是:
和
There are typos in both lines. It should be:
and