Skip to content

Commit

Permalink
temporarily remove miterJoint segment draw method
Browse files Browse the repository at this point in the history
  • Loading branch information
hongfaqiu committed Aug 5, 2021
1 parent 275afa2 commit 53d6ccb
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
20 changes: 13 additions & 7 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@ generateDataBtn.onclick = function () {
type: 'json',
colorTable: colorTable
});
particleObj.show();
statechangeBtn.disabled = false;
removeBtn.disabled = false;
loadBtn.disabled = true;
generateDataBtn.disabled = true;
statechangeBtn.innerText = '隐藏';
working = true;
particleObj.init().then(res => {
particleObj.show();
statechangeBtn.disabled = false;
removeBtn.disabled = false;
loadBtn.disabled = true;
generateDataBtn.disabled = true;
statechangeBtn.innerText = '隐藏';
working = true;
}).catch(e => {
particleObj.remove();
particleObj = undefined;
window.alert(e);
})
}
};

Expand Down
2 changes: 1 addition & 1 deletion example/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ControlPanel {
gui.add(that.options, 'fadeOpacity', 0.50, 1.00, 0.001).name("拖尾透明度").onFinishChange(onParticleSystemOptionsChange);
gui.add(that.options, 'dropRate', 0.0, 0.1).name("重置率").onFinishChange(onParticleSystemOptionsChange);
gui.add(that.options, 'dropRateBump', 0, 0.2).name("重置&速度关联率").onFinishChange(onParticleSystemOptionsChange);
gui.add(that.options, 'speedFactor', 0.05, 8).name("粒子速度").onFinishChange(onParticleSystemOptionsChange);
gui.add(that.options, 'speedFactor', 0.01, 8).name("粒子速度").onFinishChange(onParticleSystemOptionsChange);
gui.add(that.options, 'lineWidth', 0.01, 16.0).name("线宽").onFinishChange(onParticleSystemOptionsChange);
gui.add(that.options, 'dynamic').name("动态运行").onFinishChange(onParticleSystemOptionsChange);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cesium-particle",
"version": "0.5.2",
"version": "0.5.3",
"description": "cesium particle system module",
"main": "src/index.js",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions packages/shader/glsl/segmentDraw.vert
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ vec4 calculateOffsetOnMiterDirection(adjacentPoints projectedCoordinates, float
offset = vec4(offsetSign * miter * miterLength, 0.0, 0.0);
offset.x = offset.x / aspect;
} else {
offset = calculateOffsetOnNormalDirection(PointB, PointC, offsetSign);
}
offset = calculateOffsetOnNormalDirection(PointB, PointC, offsetSign);

return offset;
}
Expand Down Expand Up @@ -154,7 +154,9 @@ void main() {
gl_Position = projectedCoordinates.previous + offset;
} else {
if (pointToUse == 0) {
offset = pixelSize * calculateOffsetOnMiterDirection(projectedCoordinates, offsetSign);
offset = pixelSize * calculateOffsetOnNormalDirection(projectedCoordinates.current, projectedCoordinates.next, offsetSign);
// 暂时移除miterjoint,因为这会导致出现异常片元
// offset = pixelSize * calculateOffsetOnMiterDirection(projectedCoordinates, offsetSign);
gl_Position = projectedCoordinates.current + offset;
} else {
if (pointToUse == 1) {
Expand Down
4 changes: 0 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,3 @@ npm run buld-glsl

可使用`getFileFields()`方法可以读取.nc文件中的属性字段名、维度字段名
并配合构造函数`new Particle3D()`中传入的`fields`字段,尝试加载到地球上。

### 加载后出现奇怪的雪花

这是代码问题,暂时可通过减少粒子数量、降低粒子速度、减小线宽来降低影响
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const getFileFields = file => {
reader.readAsArrayBuffer(file);
reader.onload = function () {
var NetCDF = new netcdfjs(reader.result);
console.log(NetCDF);
let variables = NetCDF.header.variables.map(item => item.name);
let dimensions = NetCDF.header.dimensions.map(item => item.name);
resolve({variables, dimensions, raw: NetCDF});
Expand Down
2 changes: 0 additions & 2 deletions src/modules/particle3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ export default class Particle3D {
async init() {
try {
let data = await DataProcess.loadData(this.input, this.type, this.fields, this.colorTable)
console.log("data",data)
this.data = data;
this.updateViewerParameters();
this.particleSystem = new ParticleSystem(this.scene.context, data,
this.userInput, this.viewerParameters, this.colour);
this.addPrimitives();
} catch (e) {
console.error(e)
throw (e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/shader/shader.min.js

Large diffs are not rendered by default.

0 comments on commit 53d6ccb

Please sign in to comment.