有什么网站可以发布个人信息,岗顶做网站公司,页面设计工资有多少,郑州网站模板webgl中线是没有宽度的#xff0c;现实的应用中一般做法都是将线拓宽成面来绘制。默认threejs的线宽是无法调节的#xff0c;需要用有厚度的线 THREE.Line2。 先看效果图#xff1a;
看下代码#xff1a;
!DOCTYPE html
html langen
he…webgl中线是没有宽度的现实的应用中一般做法都是将线拓宽成面来绘制。默认threejs的线宽是无法调节的需要用有厚度的线 THREE.Line2。 先看效果图
看下代码
!DOCTYPE html
html langen
headmeta charsetUTF-8titleTitle/titlestylebody {width: 100%;height: 100%;}* {margin: 0;padding: 0;}.label {font-size: 20px;color: #000;font-weight: 700;}/style
/head
body
div idcontainer/div
script typeimportmap{imports: {three: ../three-155/build/three.module.js,three/addons/: ../three-155/examples/jsm/}}
/script
script typemodule
import * as THREE from three;
import Stats from three/addons/libs/stats.module.js;
import { OrbitControls } from three/addons/controls/OrbitControls.js;
import { GPUStatsPanel } from three/addons/utils/GPUStatsPanel.js;
import { CSS2DRenderer, CSS2DObject } from three/addons/renderers/CSS2DRenderer.js;
import { Line2 } from three/addons/lines/Line2.js;
import { LineMaterial } from three/addons/lines/LineMaterial.js;
import { LineGeometry } from three/addons/lines/LineGeometry.js;
let stats, labelRenderer, gpuPanel;
let camera, scene, renderer, controls;
const group new THREE.Group();
const matLines [];
let once true;
init();
initHelp();
initLight();
axesHelperWord();
animate();let data1 [{x: -50,y: 50,z: 0},{x: 50,y: 50,z: 0},{x: 50,y: -50,z: 0},{x: -50,y: -50,z: 0},{x: -50,y: 50,z: 0}
];let data2 [{x: -50,y: 0,z: 0},{x: 50,y: 1,z: 0}
];let data3 [{x: -25,y: 25,z: 0},{x: 25,y: 25,z: 0},{x: 25,y: -25,z: 0},{x: -25,y: -25,z: 0},{x: -25,y: 25,z: 0}
];let positions1 [];
let positions2 [];
let positions3 [];
let colors [];
let l data1.length;let color new THREE.Color();data1.map((v, i) {positions1.push(v.x, v.y, v.z);color.setHSL(i / l, 1.0, 0.5);colors.push(color.r, color.g, color.b);
});data2.map((v, i) {positions2.push(v.x, v.y, v.z);color.setHSL(i / l, 1.0, 0.5);colors.push(color.r, color.g, color.b);
});data3.map((v, i) {positions3.push(v.x, v.y, v.z);
});draw(positions1, colors);
draw(positions2, colors);
drawSolidLine(positions3, #f00);function draw(positions, colors) {let geometry new LineGeometry();// 虚线const matLine new LineMaterial({// 只有白色 可以显示出渐变色的效果color: 0xffffff,linewidth: 10,vertexColors: THREE.VertexColors, // 单独设置顶点颜色//resolution: // renderer.render 时加上这个属性dashed: true,dashSize: 1,gapSize: 1,defines: {USE_DASH: }});let line new Line2(geometry, matLine);line.scale.set(1, 1, 1);line.visible true;scene.add(line);matLines.push(matLine);geometry.setPositions(positions);geometry.setColors(colors);line.computeLineDistances();
}function drawSolidLine(positions, color) {let geometry new LineGeometry();// 虚线const matLine new LineMaterial({// 只有白色 可以显示出渐变色的效果color: color,linewidth: 10,// vertexColors: THREE.VertexColors, // 单独设置顶点颜色// resolution: // renderer.render 时加上这个属性dashed: false});let line new Line2(geometry, matLine);line.scale.set(1, 1, 1);line.visible true;line.rotateX(Math.PI / 3);scene.add(line);matLines.push(matLine);geometry.setPositions(positions);line.computeLineDistances();
}function init() {camera new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 10, 2000 );camera.up.set(0, 1, 0);camera.position.set(60, 40, 60);camera.lookAt(0, 0, 0);scene new THREE.Scene();scene.background new THREE.Color( #ccc );renderer new THREE.WebGLRenderer( { antialias: true } );renderer.setPixelRatio( window.devicePixelRatio );renderer.setSize( window.innerWidth, window.innerHeight );document.body.appendChild( renderer.domElement );labelRenderer new CSS2DRenderer();labelRenderer.setSize( window.innerWidth, window.innerHeight );labelRenderer.domElement.style.position absolute;labelRenderer.domElement.style.top 0px;labelRenderer.domElement.style.pointerEvents none;document.getElementById( container ).appendChild( labelRenderer.domElement );controls new OrbitControls( camera, renderer.domElement );// 设置最大最小视距controls.minDistance 20;controls.maxDistance 1000;window.addEventListener( resize, onWindowResize );stats new Stats();stats.setMode(1); // 0: fps, 1: msdocument.body.appendChild( stats.dom );gpuPanel new GPUStatsPanel( renderer.getContext() );stats.addPanel( gpuPanel );stats.showPanel( 0 );scene.add( group );
}function initLight() {const AmbientLight new THREE.AmbientLight(new THREE.Color(rgb(255, 255, 255)));scene.add( AmbientLight );
}function initHelp() {// const size 100;// const divisions 5;// const gridHelper new THREE.GridHelper( size, divisions );// scene.add( gridHelper );// The X axis is red. The Y axis is green. The Z axis is blue.const axesHelper new THREE.AxesHelper( 100 );scene.add( axesHelper );
}function axesHelperWord() {let xP addWord(X轴);let yP addWord(Y轴);let zP addWord(Z轴);xP.position.set(50, 0, 0);yP.position.set(0, 50, 0);zP.position.set(0, 0, 50);
}function addWord(word) {let name span${word}/span;let moonDiv document.createElement( div );moonDiv.className label;// moonDiv.textContent Moon;// moonDiv.style.marginTop -1em;moonDiv.innerHTML name;const label new CSS2DObject( moonDiv );group.add( label );return label;
}function onWindowResize() {camera.aspect window.innerWidth / window.innerHeight;camera.updateProjectionMatrix();renderer.setSize( window.innerWidth, window.innerHeight );
}function animate() {requestAnimationFrame( animate );// 这里请注意 // 把渲染窗口尺寸分辨率传值给材质LineMaterial的resolution属性// resolution属性值会在着色器代码中参与计算if (matLines.length once) {matLines.forEach(matLine {matLine.resolution.set(window.innerWidth, window.innerHeight); // resolution of the viewport});once false;}stats.update();controls.update();labelRenderer.render( scene, camera );renderer.render( scene, camera );
}
/script
/body
/html 文章转载自: http://www.morning.njstzsh.com.gov.cn.njstzsh.com http://www.morning.hqwtm.cn.gov.cn.hqwtm.cn http://www.morning.cthrb.cn.gov.cn.cthrb.cn http://www.morning.mdgb.cn.gov.cn.mdgb.cn http://www.morning.rnpnn.cn.gov.cn.rnpnn.cn http://www.morning.sgrwd.cn.gov.cn.sgrwd.cn http://www.morning.ydzly.cn.gov.cn.ydzly.cn http://www.morning.rgksz.cn.gov.cn.rgksz.cn http://www.morning.ppllj.cn.gov.cn.ppllj.cn http://www.morning.cfnht.cn.gov.cn.cfnht.cn http://www.morning.junmap.com.gov.cn.junmap.com http://www.morning.jmtrq.cn.gov.cn.jmtrq.cn http://www.morning.nxpqw.cn.gov.cn.nxpqw.cn http://www.morning.fbxlj.cn.gov.cn.fbxlj.cn http://www.morning.pmjhm.cn.gov.cn.pmjhm.cn http://www.morning.bxrlt.cn.gov.cn.bxrlt.cn http://www.morning.mcndn.cn.gov.cn.mcndn.cn http://www.morning.mypxm.com.gov.cn.mypxm.com http://www.morning.trrd.cn.gov.cn.trrd.cn http://www.morning.hqxyt.cn.gov.cn.hqxyt.cn http://www.morning.ydhck.cn.gov.cn.ydhck.cn http://www.morning.qsmdd.cn.gov.cn.qsmdd.cn http://www.morning.sjbty.cn.gov.cn.sjbty.cn http://www.morning.rqnhf.cn.gov.cn.rqnhf.cn http://www.morning.wkpfm.cn.gov.cn.wkpfm.cn http://www.morning.mbnhr.cn.gov.cn.mbnhr.cn http://www.morning.nnjq.cn.gov.cn.nnjq.cn http://www.morning.rmqlf.cn.gov.cn.rmqlf.cn http://www.morning.qpnmd.cn.gov.cn.qpnmd.cn http://www.morning.bqwrn.cn.gov.cn.bqwrn.cn http://www.morning.qllcm.cn.gov.cn.qllcm.cn http://www.morning.lmctj.cn.gov.cn.lmctj.cn http://www.morning.xstfp.cn.gov.cn.xstfp.cn http://www.morning.attorneysportorange.com.gov.cn.attorneysportorange.com http://www.morning.whothehellami.com.gov.cn.whothehellami.com http://www.morning.kqpxb.cn.gov.cn.kqpxb.cn http://www.morning.rhsg.cn.gov.cn.rhsg.cn http://www.morning.mbqyl.cn.gov.cn.mbqyl.cn http://www.morning.hnkkf.cn.gov.cn.hnkkf.cn http://www.morning.csnch.cn.gov.cn.csnch.cn http://www.morning.pbmkh.cn.gov.cn.pbmkh.cn http://www.morning.dpruuode.cn.gov.cn.dpruuode.cn http://www.morning.zdkzj.cn.gov.cn.zdkzj.cn http://www.morning.fmqng.cn.gov.cn.fmqng.cn http://www.morning.lhxrn.cn.gov.cn.lhxrn.cn http://www.morning.qbrdg.cn.gov.cn.qbrdg.cn http://www.morning.fylsz.cn.gov.cn.fylsz.cn http://www.morning.ljwyc.cn.gov.cn.ljwyc.cn http://www.morning.grpbt.cn.gov.cn.grpbt.cn http://www.morning.ffwrq.cn.gov.cn.ffwrq.cn http://www.morning.hjrjr.cn.gov.cn.hjrjr.cn http://www.morning.rdxp.cn.gov.cn.rdxp.cn http://www.morning.frsbf.cn.gov.cn.frsbf.cn http://www.morning.wcczg.cn.gov.cn.wcczg.cn http://www.morning.dyrzm.cn.gov.cn.dyrzm.cn http://www.morning.mczjq.cn.gov.cn.mczjq.cn http://www.morning.bykqg.cn.gov.cn.bykqg.cn http://www.morning.kqcqr.cn.gov.cn.kqcqr.cn http://www.morning.dnqpq.cn.gov.cn.dnqpq.cn http://www.morning.rmlz.cn.gov.cn.rmlz.cn http://www.morning.wlddq.cn.gov.cn.wlddq.cn http://www.morning.tpdg.cn.gov.cn.tpdg.cn http://www.morning.nlysd.cn.gov.cn.nlysd.cn http://www.morning.lpmlx.cn.gov.cn.lpmlx.cn http://www.morning.gcdzp.cn.gov.cn.gcdzp.cn http://www.morning.plydc.cn.gov.cn.plydc.cn http://www.morning.ymqrc.cn.gov.cn.ymqrc.cn http://www.morning.c7495.cn.gov.cn.c7495.cn http://www.morning.nmhpq.cn.gov.cn.nmhpq.cn http://www.morning.jhxdj.cn.gov.cn.jhxdj.cn http://www.morning.mjtft.cn.gov.cn.mjtft.cn http://www.morning.ktnmg.cn.gov.cn.ktnmg.cn http://www.morning.wqpr.cn.gov.cn.wqpr.cn http://www.morning.jikuxy.com.gov.cn.jikuxy.com http://www.morning.sxfnf.cn.gov.cn.sxfnf.cn http://www.morning.nthyjf.com.gov.cn.nthyjf.com http://www.morning.rsdm.cn.gov.cn.rsdm.cn http://www.morning.byzpl.cn.gov.cn.byzpl.cn http://www.morning.tnqk.cn.gov.cn.tnqk.cn http://www.morning.lgcqj.cn.gov.cn.lgcqj.cn