From b216930430c1de5b806faca54b90353a81c7a345 Mon Sep 17 00:00:00 2001 From: liuxianghui <519646741@qq.com> Date: Wed, 10 Nov 2021 17:13:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=AF=AD=E9=9F=B3=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/info/model/model-info-facility.ts | 2 + src/app/babylon/tool/speaking-tool.ts | 64 +++++++++++++++++++ .../view/facility-window/facility-window.ts | 5 ++ yarn.lock | 6 +- 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 src/app/babylon/tool/speaking-tool.ts diff --git a/src/app/babylon/model/info/model/model-info-facility.ts b/src/app/babylon/model/info/model/model-info-facility.ts index 3603b59..8d9a2df 100644 --- a/src/app/babylon/model/info/model/model-info-facility.ts +++ b/src/app/babylon/model/info/model/model-info-facility.ts @@ -3,6 +3,7 @@ import { Button, Control, Ellipse, Rectangle, Vector2WithInfo } from "@babylonjs import { ConfigManager } from "src/app/babylon/controller/config-manager"; import { SceneManager } from "src/app/babylon/controller/scene-manager"; import { BabylonUIStyleTool } from "src/app/babylon/tool/babylon-ui-style-tool"; +import { SpeakingTool } from "src/app/babylon/tool/speaking-tool"; import { TsTool } from "src/app/babylon/tool/ts-tool"; import { FacilityWindow } from "src/app/babylon/view/facility-window/facility-window"; import { FacilityInfoInSceneWindow } from "src/app/babylon/view/facilityinfoinscene-window/facilityinfoinscene-window"; @@ -124,6 +125,7 @@ export class ModelInfo_facility extends ModelInfo { // this.onClickMeshIconBtn(eventData,eventState); FacilityInfoInSceneWindow.instance.selectFacilityInfo(this); + // SpeakingTool.Instance.speak("这是离线版"); } //展示属性 diff --git a/src/app/babylon/tool/speaking-tool.ts b/src/app/babylon/tool/speaking-tool.ts new file mode 100644 index 0000000..5fb710b --- /dev/null +++ b/src/app/babylon/tool/speaking-tool.ts @@ -0,0 +1,64 @@ + +/** + * 语音工具 + */ +export class SpeakingTool { + + private static instance: SpeakingTool; + + static get Instance() { + if (SpeakingTool.instance == null) { + SpeakingTool.instance = new SpeakingTool(); + } + return SpeakingTool.instance; + } + + + /** + * 阅读一段文字 + * @param msg + */ + speak(msg: string) { + if (this.isIE()) { + + } + else { + let speakMsg = new SpeechSynthesisUtterance(msg); + speakMsg.lang = "zh-CN"; + speakMsg.rate = 1; + speakMsg.pitch = 1.5; + window.speechSynthesis.speak(speakMsg); + + return speakMsg; + } + } + + /** + * 暂停正在进行的阅读 + * @param speakMsg + */ + pause() { + window.speechSynthesis.pause(); + } + /** + * 继续之前暂停的阅读 + */ + resume() { + window.speechSynthesis.resume(); + } + + /** + * IE浏览器 + */ + private isIE() { + // if ("ActiveXObject" in window) { + // console.log("IE 浏览器") + // return true; + // } + // else { + // return false; + // } + return false; + } + +} \ No newline at end of file diff --git a/src/app/babylon/view/facility-window/facility-window.ts b/src/app/babylon/view/facility-window/facility-window.ts index 3ee7da4..a430a89 100644 --- a/src/app/babylon/view/facility-window/facility-window.ts +++ b/src/app/babylon/view/facility-window/facility-window.ts @@ -25,6 +25,7 @@ import { BuildingStatus } from '../../controller/status/building-status'; import { IndoorStatus } from '../../controller/status/indoor-status'; import { StatusManager } from '../../controller/status/status-manager'; import { UIManager } from '../../controller/ui-manager'; +import { BuildingType } from '../../model/data/institution/building/building-data'; import { JYZInfoMoudleType } from '../../model/data/institution/jyz-show-data'; import { FacilityPosType, ModelData_facility, FacilityShowType, FacilityType } from '../../model/data/model-data/model-data-facility'; import { TransformData } from '../../model/data/transform-data'; @@ -337,6 +338,10 @@ export class FacilityWindow extends UIBase { // ThreeDimensionalHomeComponent.instance.openSnackBar("请先选中目标建筑"); return } + else if (currentBuidngItem.getBuildingType() == BuildingType.Environment) { + alert("请选中主体建筑后,再进行标注") + return + } Event_ChangeFacility.dispatch(facilityData, ModelChangeType.Add, null); diff --git a/yarn.lock b/yarn.lock index e2d741a..20611a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -122,7 +122,7 @@ resolved "https://registry.npmmirror.com/@angular/animations/download/@angular/animations-9.1.13.tgz?cache=0&sync_timestamp=1634753072212&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2F%40angular%2Fanimations%2Fdownload%2F%40angular%2Fanimations-9.1.13.tgz#561305f7bf4a7a5ea3ff172d6fac31615667acb0" integrity sha1-VhMF979Kel6j/xctb6wxYVZnrLA= -"@angular/cdk@^9.0.0": +"@angular/cdk@^9.0.0", "@angular/cdk@^9.2.4": version "9.2.4" resolved "https://registry.npmmirror.com/@angular/cdk/download/@angular/cdk-9.2.4.tgz#8413958bd275e4c34be3b96f56444671dd30ba93" integrity sha1-hBOVi9J15MNL47lvVkRGcd0wupM= @@ -4976,9 +4976,9 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -echarts@^4.6.0: +echarts@^4.9.0: version "4.9.0" - resolved "https://registry.nlark.com/echarts/download/echarts-4.9.0.tgz?cache=0&sync_timestamp=1632191355993&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fecharts%2Fdownload%2Fecharts-4.9.0.tgz#a9b9baa03f03a2a731e6340c55befb57a9e1347d" + resolved "https://registry.npmmirror.com/echarts/download/echarts-4.9.0.tgz?cache=0&sync_timestamp=1635741929711&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fecharts%2Fdownload%2Fecharts-4.9.0.tgz#a9b9baa03f03a2a731e6340c55befb57a9e1347d" integrity sha1-qbm6oD8Doqcx5jQMVb77V6nhNH0= dependencies: zrender "4.3.2"