@@ -38,7 +38,7 @@ import "@babylonjs/core/Culling/ray"; // нужно для работы клик
3838import { PrefetchResourcesManager } from "./Models/PrefetchResourcesManager" ;
3939import { WebXRInterface } from "./AsyncModules/AsyncModuleInterfaces" ;
4040import { PlayAudioHelper } from "./WorkWithAudio/PlayAudioHelper" ;
41- import { KeyboardEventTypes } from "@babylonjs/core" ;
41+ import { KeyboardEventTypes , PointerEventTypes } from "@babylonjs/core" ;
4242
4343export class Viewer {
4444 private currentImage : DynamicPhotoDome | null = null ;
@@ -68,7 +68,7 @@ export class Viewer {
6868
6969 private backgroundRadius = 500 ;
7070
71- public createScene ( ) {
71+ public createScene ( minFov ?: number , maxFov ?: number ) {
7272 const canvas = document . querySelector ( "#renderCanvas" ) as HTMLCanvasElement ;
7373 this . canvas = canvas ;
7474 const engine = new Engine ( canvas , true , {
@@ -145,6 +145,7 @@ export class Viewer {
145145 camera . angularSensibility = - 10000 ;
146146 camera . attachControl ( canvas , true ) ;
147147 camera . inputs . addGamepad ( ) ;
148+ camera . fov = 1 ;
148149 this . freeCamera = camera ;
149150
150151 if ( "xr" in window . navigator ) {
@@ -173,6 +174,20 @@ export class Viewer {
173174
174175 scene . actionManager = new ActionManager ( scene ) ;
175176
177+ scene . onPointerObservable . add ( e => {
178+ const event = e . event as WheelEvent ;
179+ let fov = this . freeCamera . fov ;
180+ if ( event . deltaY > 0 ) {
181+ fov += 0.1 ;
182+ } else {
183+ fov -= 0.1 ;
184+ }
185+ minFov = minFov ?? 0.8 ;
186+ maxFov = maxFov ?? 1.8 ;
187+ fov = Math . max ( Math . min ( fov , maxFov ) , minFov ) ;
188+ this . freeCamera . fov = fov ;
189+ } , PointerEventTypes . POINTERWHEEL ) ;
190+
176191 if ( BuildConfiguration . NeedDebugLayer ) {
177192 import ( "./AsyncModules/InspectorLogic" ) . then ( ( module ) => {
178193 module . InspectorLogic . registerInspector ( scene ) ;
0 commit comments