Commit 0bfc17a3 authored by 张启明's avatar 张启明

test: 添加粒子特效、模型剖切

parent 8cbe2c04
<div id="container">
<div class="widgets">
<div class="widgets text-white">
<app-measure-handler></app-measure-handler>
<app-sight-line></app-sight-line>
<app-skyline></app-skyline>
......@@ -7,6 +7,8 @@
<app-profile></app-profile>
<app-underground></app-underground>
<app-soil-excavation></app-soil-excavation>
<app-particle-effect></app-particle-effect>
<app-tileset-clipping></app-tileset-clipping>
<app-layer-manager></app-layer-manager>
</div>
</div>
......@@ -12,6 +12,8 @@ import {
ProfileComponent,
UndergroundComponent,
SoilExcavationComponent,
ParticleEffectComponent,
TilesetClippingComponent,
} from './components';
@NgModule({
......@@ -25,6 +27,8 @@ import {
ProfileComponent,
UndergroundComponent,
SoilExcavationComponent,
ParticleEffectComponent,
TilesetClippingComponent,
],
imports: [
BrowserModule,
......
......@@ -6,3 +6,5 @@ export * from './viewshed';
export * from './profile';
export * from './underground';
export * from './soil-excavation';
export * from './particle-effect';
export * from './tileset-clipping';
......@@ -8,7 +8,7 @@ import { ViewerService } from 'src/app/services';
})
export class MeasureHandlerComponent implements OnInit {
public handleMeasure: (measureMode: number, isGround: boolean, showLabel: boolean) => any;
public handleMeasure: (measureMode: number, isGround?: boolean, showLabel?: boolean) => any;
public measureMode = smart3d.MeasureMode;
constructor(
......
export * from './particle-effect.component';
<div>
<button (click)="enableParticleEffect('rain')">开启雨</button>
<input type="range" (change)="handleChangeRange('rain', $event)" max="1" min="0" step="0.1" [disabled]="rainEffect === undefined">
<button (click)="enableParticleEffect('snow')">开启雪</button>
<input type="range" (change)="handleChangeRange('snow', $event)" max="1" min="0" step="0.1" [disabled]="snowEffect === undefined">
<button (click)="enableParticleEffect('fog')">开启雾</button>
<input type="range" (change)="handleChangeRange('fog', $event)" max="1" min="0" step="0.1" [disabled]="fogEffect === undefined">
<button (click)="enableParticleEffect('smoke')">添加烟</button>
<button (click)="enableParticleEffect('fire')">添加火</button>
</div>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ParticleEffectComponent } from './particle-effect.component';
describe('ParticleEffectComponent', () => {
let component: ParticleEffectComponent;
let fixture: ComponentFixture<ParticleEffectComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ParticleEffectComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ParticleEffectComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { ViewerService } from 'src/app/services';
@Component({
selector: 'app-particle-effect',
templateUrl: './particle-effect.component.html',
styleUrls: ['./particle-effect.component.css']
})
export class ParticleEffectComponent implements OnInit {
private particleEffect;
public rainEffect;
public snowEffect;
public fogEffect;
constructor(
private viewerService: ViewerService,
) { }
ngOnInit(
) {
const viewer = this.viewerService.viewer;
this.particleEffect = new smart3d.ParticleEffect(viewer);
}
enableParticleEffect(type: string) {
const viewer = this.viewerService.viewer;
const cartesian = Cesium.Cartesian3.fromDegrees(115, 24, 250);
let options;
switch (type) {
case 'rain':
if (undefined === this.rainEffect) {
this.rainEffect = new smart3d.RainEffect(viewer.scene);
this.rainEffect.add();
}
break;
case 'snow':
if (undefined === this.snowEffect) {
this.snowEffect = new smart3d.SnowEffect(viewer.scene);
this.snowEffect.add();
}
break;
case 'fog':
if (undefined === this.fogEffect) {
this.fogEffect = new smart3d.FogEffect(viewer.scene);
this.fogEffect.add();
}
break;
case 'smoke':
const entity = viewer.entities.add({
position: cartesian
});
options = {
particleMode: smart3d.ParticleMode.SMOKE,
entity,
minimumSpeed: 1,
maximumSpeed: 5,
minimumParticleLife: 1,
maximumParticleLife: 4,
startScale: 1,
endScale: 5,
emissionRate: 5,
imageSize: 25
};
this.particleEffect.add(options);
viewer.camera.lookAt(cartesian, new Cesium.Cartesian3(-100, 0, 100));
viewer.camera._setTransform(Cesium.Matrix4.IDENTITY);
break;
case 'fire':
const fireEntity = viewer.entities.add({
position: cartesian
});
options = {
particleMode: smart3d.ParticleMode.FIRE,
entity: fireEntity,
minimumSpeed: 1,
maximumSpeed: 5,
minimumParticleLife: 1,
maximumParticleLife: 20,
startScale: 0,
endScale: 10,
emissionRate: 14,
imageSize: 10
};
this.particleEffect.add(options);
viewer.camera.lookAt(cartesian, new Cesium.Cartesian3(-100, 0, 100));
viewer.camera._setTransform(Cesium.Matrix4.IDENTITY);
break;
}
}
handleChangeRange(type: string, e): void {
const value: number = Cesium.Math.clamp(e.target.value, 0.0, 1.0);
switch (type) {
case 'rain':
break;
case 'snow':
this.snowEffect.update(value);
break;
case 'fog':
this.fogEffect.update(value);
break;
}
}
}
<div class="profile-container">
<div>
<button (click)="startProfileAnalyze()">点击开始剖面分析</button>
剖面分析结果长度:{{ result.length }}
</div>
\ No newline at end of file
<div class="soil-excavation-container">
<div>
<label for="soil-excavation">开挖深度:</label>
<input type="number" id="soil-excavation" min="0" [(ngModel)]="depth" (ngModelChange)="changeDepth($event)" />
<button (click)="startExcavation()">开挖地形</button>
</div>
\ No newline at end of file
<input type="number" id="soil-excavation" min="0" [(ngModel)]="depth" />
<button (click)="handleSoilExcavation()">开挖地形</button>
</div>
......@@ -20,11 +20,8 @@ export class SoilExcavationComponent implements OnInit {
this.terrainClip.updateDepth(this.depth);
}
changeDepth(depth: number) {
this.terrainClip.updateDepth(depth);
}
startExcavation() {
handleSoilExcavation() {
this.terrainClip.updateDepth(this.depth);
this.terrainClip.start(this.depth);
}
......
export * from './tileset-clipping.component';
<select [(ngModel)]="clippingPlane">
<option value="Z">Z</option>
<option value="Y">Y</option>
<option value="X">X</option>
</select>
<button (click)="enableClipping()">开启模型剖切</button>
<button (click)="enableClipping(false)">关闭模型剖切</button>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TilesetClippingComponent } from './tileset-clipping.component';
describe('TilesetClippingComponent', () => {
let component: TilesetClippingComponent;
let fixture: ComponentFixture<TilesetClippingComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TilesetClippingComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TilesetClippingComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { ViewerService } from 'src/app/services';
const tilesetUrl = 'https://www.south-smart.com/cesium/modeldata/nanfangcehuiBIM/NFCH0911/CHDLFC/tileset.json';
@Component({
selector: 'app-tileset-clipping',
templateUrl: './tileset-clipping.component.html',
styleUrls: ['./tileset-clipping.component.css']
})
export class TilesetClippingComponent implements OnInit {
public clippingPlane: 'X' | 'Y' | 'Z' = 'Z';
private tileset;
private clipping;
constructor(
private viewerService: ViewerService,
) { }
ngOnInit() {
}
enableClipping(enable?: boolean) {
const viewer = this.viewerService.viewer;
if (this.clipping) {
this.clipping.destroy();
}
if (false === enable) {
return;
}
const clippingOptions = {
dimensions: 2,
material: Cesium.Color.BLUE.withAlpha(0.2),
outline: true,
outlineColor: Cesium.Color.RED,
edgeStylingEnabled: true,
debugBoundingVolumesEnabled: true,
};
const that = this;
function createAndStartClipping() {
that.clipping = new smart3d.Clipping(viewer, clippingOptions);
that.clipping.start(that.tileset, smart3d.ClippingMode[that.clippingPlane]);
}
if (undefined === this.tileset) {
this.tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: tilesetUrl,
}));
this.tileset.readyPromise.then(tileset => {
createAndStartClipping();
viewer.flyTo(tileset);
});
} else {
createAndStartClipping();
viewer.flyTo(this.tileset);
}
}
}
<div class="underground-container">
<div>
不透明度:<input type="number" id="" max="1" min="0" step="0.1" [(ngModel)]="alpha" />
<button (click)="activateUndergroundMode()">开启地下模式</button>
<button (click)="deactivateUndergroundMode()">取消地下模式</button>
</div>
\ No newline at end of file
</div>
.form-container {
/* display: flex; */
/* flex-direction: column; */
/* flex-grow: 0; */
color: white;
}
\ No newline at end of file
<div class="form-container">
<div>
<label for="horizontalAngle">水平张角:</label>
<input type="number" id="horizontalAngle" [(ngModel)]="horizontalAngle"/>
<label for="verticalAngle">垂直张角:</label>
......
/* You can add global styles to this file, and also import other style files */
body {
margin: 0;
}
\ No newline at end of file
}
.text-white {
color: white;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment