naver / egjs-view3d

Fast & customizable 3D model viewer for everyone
https://naver.github.io/egjs-view3d
MIT License
199 stars 30 forks source link

Disable negative rotation on the Y axis, is it possible to set via options? #66

Open StefanThumann opened 1 year ago

StefanThumann commented 1 year ago

I need to use the following options for my plugin:

disablePitch: true,

minY: 0,

maxY: 90

Background is that I want to disable negative rotation on the Y-Axis for the model.

Is it possible to place these options inside the plugin init code like this?

plugins: [new View3D.RotateControl({
    
disablePitch: true,
    
minY: 0,
    
maxY: 90,

})]
WoodNeck commented 1 year ago

Hello @StefanThumann View3D doesn't provide pitchRange yet, but I think we should provide it.

StefanThumann commented 1 year ago

I have a working solution for this now. I place this piece of code after the plugin init code and it disables the negative rotation on the x axis.


// Wait for the model to load before calling updatePitch


view3D.on("load", () => {
    
  const camera = view3D.camera;
    
  const onRender = () => {

  if (camera.pitch < 0) {
            
    camera.pitch = 0;
        
  }

    
};
    

view3D.on("beforeRender", onRender);
});