Hey, everybody. I am creating a project on Cesium + Three, and I have a question of creating a DashLine. The problem is that I’m trying to do the following example: three.js examples.
I have lines are not displayed or behave unpredictably, for example, just in the scene as a grid and constantly moving. And I need just a small vertical dotted line. Here’s how I get the coordinates for it:
let positionUp = Cartesian3.fromDegrees(37.0, 125.0, 10000.0);
let positionBottom = Cartesian3.fromDegrees(37.0, 125.0, 0);
let positions = [positionBottom, positionUp].map(cartesian => {
let cartographic = Cartographic.fromCartesian(cartesian);
return new Vector3(
Math.toDegrees(cartographic.longitude),
Math.toDegrees(cartographic.latitude),
cartographic.height
);
});
const positionsArray = [];
positions.forEach(pos => {
positionsArray.push(pos.x, pos.y, pos.z);
});
// Create the geometry and material for the dashed line
const geometry = new LineGeometry()
geometry.setPositions( positionsArray );
const matLineDashed = new LineMaterial( {
color: 0xffffff,
linewidth: 5, // in world units with size attenuation, pixels otherwise
vertexColors: true,
dashed: true,
dashSize: 10,
gapSize: 5,
alphaToCoverage: true,
} );
// Create the line
const line = new Line2(geometry, matLineDashed);
line.computeLineDistances();
line.scale.set( 1, 1, 1 );
scene.add(line)
Why doesn’t it work?