Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Gizmo #51

Open
Identity-labs opened this issue May 9, 2024 · 1 comment
Open

[BUG] Gizmo #51

Identity-labs opened this issue May 9, 2024 · 1 comment

Comments

@Identity-labs
Copy link

You can't switch from translate to rotate mode it's breaking the gizmo, and you can go back to translate mode after that

"ngx-three": "^0.31.0",
"rxjs": "~7.8.1",
"three": "^0.164.1",
"@types/three": "~0.164.0",
<th-canvas [thStats]="true" [renderOnDemand]="renderOnDemand" #canvas>
    <th-scene>
        <th-mesh #model
            [(position)]="selectedElementPosition"
            [(rotation)]="selectedElementRotation"
            [(scale)]="selectedElementScale">
        </th-mesh>

        <th-perspectiveCamera
            [ngSwitch]="controlType"
            #camera
            [position]="cameraPosition"
            [rotation]="cameraRotation"
        >
            <th-orbitControls *ngSwitchCase="'orbit'" />
            <th-mapControls *ngSwitchCase="'map'" />
            <th-arcballControls *ngSwitchCase="'arcball'" />
            <th-transformControls *ngSwitchCase="'transform'"
                [object]="model.objRef"
                [mode]="editorMode"
                [threeEvents]="transformEvents" />
            <th-dragControls
                *ngSwitchCase="'drag'"
                [args]="[[model.objRef], camera.objRef, canvas.hostElement.nativeElement]"
            />
            <th-flyControls *ngSwitchCase="'fly'" />
            <th-trackballControls *ngSwitchCase="'trackball'" />
            <th-firstPersonControls *ngSwitchCase="'firstpersion'" />
        </th-perspectiveCamera>
    </th-scene>
</th-canvas>

I change editorMode width addEventListener on keydown
You can go back to translate mode without any error but control is not showing

@demike
Copy link
Owner

demike commented Jun 25, 2024

The modified on-demand-rendering example
works as expected
```

Render On-Demand orbit map arcball transform drag fly trackball firstpersion
Change Mode
<th-object3D
  #model
  loadGLTF
  [url]="glbPath"
  (onClick)="selected = !selected"
  [scale]="selected ? [2, 2, 2] : [1, 1, 1]"
/>
<th-gridHelper [args]="[10, 10]" />
<th-pointLight [position]="[10, 10, 10]" [decay]="0" />

<th-perspectiveCamera
  [ngSwitch]="controlType"
  #camera
  [args]="[45, 2, 0.1, 100]"
  [position]="[10, 10, 10]"
  [lookAt]="[0, 0, 0]"
>
  <th-orbitControls *ngSwitchCase="'orbit'" />
  <th-mapControls *ngSwitchCase="'map'" />
  <th-arcballControls *ngSwitchCase="'arcball'" />
  <th-transformControls *ngSwitchCase="'transform'" [object]="model.objRef" [mode]="mode" />
  <th-dragControls
    *ngSwitchCase="'drag'"
    [args]="[[model.objRef], camera.objRef, canvas.hostElement.nativeElement]"
  />
  <th-flyControls *ngSwitchCase="'fly'" />
  <th-trackballControls *ngSwitchCase="'trackball'" />
  <th-firstPersonControls *ngSwitchCase="'firstpersion'" />
</th-perspectiveCamera>
```
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ASSET_PATH } from '../assets';
import { TransformControlsMode } from 'three/examples/jsm/controls/TransformControls';

@Component({
  selector: 'app-on-demand-example',
  templateUrl: './on-demand-example.component.html',
  styleUrls: ['./on-demand-example.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class OnDemandExampleComponent {
  protected controlType = 'transform';
  protected renderOnDemand = true;
  protected selected = false;
  protected mode: TransformControlsMode = 'translate';
  public readonly glbPath = `${ASSET_PATH}DamagedHelmet.glb`;

  public changeMode() {
    if (this.mode === 'translate') {
      this.mode = 'rotate';
    } else if (this.mode === 'rotate') {
      this.mode = 'translate';
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants