nartc / angular-three

🧊 THREE.js integration for Angular 🧊
https://angular-three.netlify.app/
MIT License
306 stars 26 forks source link

[Feature] Disable helper functions without removing attribute #104

Closed IRobot1 closed 2 years ago

IRobot1 commented 2 years ago

While working on new trigger example, I added the ngtSpotLightHelper to a spot light to help visualize where the spot light was pointing.

<ngt-spot-light #spot (ready)="off(spot)" name="spot" 
  ngtSpotLightHelper castShadow 
  [position]="[1, 10, -2]" angle="0.3" penumbra="1" 
  [target]="sphere.instance.value">
</ngt-spot-light>

After getting everything working, I wanted to disable the helper. However, there doesn't appear to be a way to do this without completely removing it from the ngt-spot-light element.

This feature request is to ask for a way to disable helper directives without removing from the code.

IRobot1 commented 2 years ago

One solution is to pass the helper into the ready function and set visible to false. Set visible to true when needed.

<ngt-spot-light #spot (ready)="off(spot, helper)" 
  #helper="ngtSpotLightHelper" ngtSpotLightHelper 
  off(spot: NgtSpotLight, helper: NgtSpotLightHelper) {
    helper.instance.value.visible = false;
  }
nartc commented 2 years ago

@IRobot1 beta-18 exposes helperVisible as an Input.