当前位置:网站首页>【threejs】根据点绘制直线
【threejs】根据点绘制直线
2023-01-19 15:15:56【章井】
实现代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My first three.js app</title>
<style> body {
margin: 0; } #info {
position: absolute; top: 100px; width: 100%; text-align: center; z-index: 100; display:block; color: #fff; } </style>
</head>
<body>
<div id="info">Description</div>
<script src="./index_script/index_script_three.js"></script>
<script> const renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); const camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 500 ); camera.position.set( 0, 0, 100 ); camera.lookAt( 0, 0, 0 ); const scene = new THREE.Scene(); //create a blue LineBasicMaterial const material = new THREE.LineBasicMaterial( {
color: 0xe4e4e4 } ); const points = []; points.push( new THREE.Vector3( - 10, 0, 0 ) ); points.push( new THREE.Vector3( 0, 10, 0 ) ); points.push( new THREE.Vector3( 10, 0, 0 ) ); const geometry = new THREE.BufferGeometry().setFromPoints( points ); const line = new THREE.Line( geometry, material ); scene.add( line ); function animate() {
requestAnimationFrame( animate ); renderer.render( scene, camera ); }; animate(); </script>
</body>
</html>
实现效果

边栏推荐
猜你喜欢
随机推荐
- flutter 拖拽控件 Draggable DragTarget
- flutter 视频播放控件 Chewie video_play
- Kotlin将函数作为参数传递
- NDK开发
- 带你玩转字符串旋转问题
- MSR 5660设备进行流量整形和带宽保证的实现案例
- SVN报错Skipped ‘xxxController.class.php‘ -- Node remains in conflict
- uni-app 190扫一扫加入群聊功能(二)
- liunx执行pecl install swoole报错“failed to run `phpize‘”
- 第一章 Golang开山篇
- 第二章 Golang的概述
- Dos的常用指令
- uni-app 189扫一扫添加群聊功能(一)
- uni-app 186多进程实现(一)
- uni-app 187多进程实现(二)
- uni-app 188修复弹框问题
- uni-app 184查看好友朋友圈完善(五)
- uni-app 182查看好友朋友圈完善(三)
- uni-app 183查看好友朋友圈完善(四)
- uni-app 179转发名片功能
- uni-app 178添加背景提示音(二)
- uni-app 181查看好友朋友圈完善(二)
- uni-app 180查看好友朋友圈完善(一)
- uni-app 176添加背景提示音(一)
- uni-app 175app端兼容处理(二)
- 关于双碳中的一些单位换算
- OpenMP 环境变量使用总结
- TiCDC 源码阅读(三)TiCDC 集群工作过程解析
- OpenMP 环境变量使用总结
- Inside OpenStack Technology
- MapReduce 实验:二次排序
- scrapy框架利用crawlspider全站爬取招聘信息
- scrapy爬虫框架全栈爬取招聘所有数据3000多条记录
- scrapy爬虫框架介绍与实战
- MeterSphere使用beanshell全局断言解决引用JSONObject问题
- 多种汉语方言语音落地应用,微软智能语音解锁更多交互场景
- 超越TensorFlow?Yann LeCun:“Why? PyTorch. That's why.”
- CTA-敏感行为-AppOps方案
- 年金保险排名前十的保险是哪个,安全吗
- 支付宝的年金保险值得入手吗?安全吗?





