照着官网的例子打的,运行时报了这个错误
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{margin: 0;}
#title{font-size: 40px;font-weight: bold;color: red;text-align: center;}
#threedCanvas{width: 800px;height: 600px;border: solid 0px #000;margin: 0 auto;}
canvas{width: 100%;height: 100%;}
</style>
</head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/three.js/r128/three.min.js"></script>
<script>
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 500 );
camera.position.set( 0, 0, 100 );
camera.lookAt( 0, 0, 0 );
var scene = new THREE.Scene();
//create a blue LineBasicMaterial
var material = new THREE.LineBasicMaterial( { color: 0x0000ff } );
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3( -10, 0, 0) );
geometry.vertices.push(new THREE.Vector3( 0, 10, 0) );
geometry.vertices.push(new THREE.Vector3( 10, 0, 0) );
var line = new THREE.Line( geometry, material );
scene.add( line );
renderer.render( scene, camera );
</script>
</body>
</html>
一开始以为是three版本太高了,换了几个版本还是一样,有没有大佬解惑一下
你好朋友,我发现同样的问题
构造器以及下面的api都已经被废弃。
然后google了一番发现是版本的问题,125版本就不再支持这个api了,如果还需要就用他的子类BufferGeometry。
地址:https://github.com/mrdoob/thr...
我贴一下我的代码,也给了注释希望能帮到你!
互联网第一次解决问题,我也是新人,一起加油啦!