Default Navigation speed in Forge Viewer

前端 未结 2 1275
无人及你
无人及你 2021-01-23 09:50

How can the default navigation speed be changed in the Forge Viewer? The default setting is far to fast for my sample models. I should like to write code so that the speed may b

相关标签:
2条回答
  • 2021-01-23 10:14

    Copy an existing navigation tool from the viewer3D.js implementation, modify the speed parameters as you wish or expose methods to do so dynamically from your app, then set it active.

    You can check the implementation of OrbitDollyPanTool L#14545 in viewer3D.js

    Autodesk.Viewing.OrbitDollyPanTool = function( viewerImpl, viewerApi ){
        var avp = Autodesk.Viewing.Private;
        var _this = this;
        var kScreenEpsilon = 0.001;
        var kEpsilon = 0.00001;
        var kAutoDeltaZ  = 1.5;         // Dolly increment
        var kAutoDeltaXY = 0.01;
        var kAutoScreenXY = 20;
        var kDollyDragScale = 100.0;
        var kDollyPinchScale = 0.5;
        var kOrbitScale = 2.0;
    
        // ...
    

    That tool is instantiated as follow (L#40923):

    Viewer3D.prototype.createControls = function( ) {
        var self = this;
        var impl = self.impl;
    
        self.navigation = new av.Navigation(impl.camera);
        self.__initAutoCam(impl);
    
        self.utilities = new av.ViewingUtilities(impl, self.autocam, self.navigation);
        self.clickHandler = new av.DefaultHandler(impl, self.navigation, self.utilities);
        self.toolController = new av.ToolController(impl, self, self.autocam, self.utilities, self.clickHandler);
        self.toolController.registerTool( new av.GestureHandler(self) );
    
        self.toolController.registerTool( av.theHotkeyManager );
        self.toolController.activateTool( av.theHotkeyManager.getName() );
    
        self.registerUniversalHotkeys();
    
        self.toolController.registerTool( new av.OrbitDollyPanTool(impl, self) );
        self.toolController.activateTool( "gestures" );
    
        return self.toolController;
    }; 
    
    0 讨论(0)
  • 2021-01-23 10:30

    I recently found out that you can use viewer.navigation.fitBounds(true, THREE.Box3) which will impact the navigation speed to match the extends defined by those bounds.

    0 讨论(0)
提交回复
热议问题