Closed yywf77 closed 2 years ago
Please provide example of how you are resetting scene background. Also, does just adding NgtEffectComposer with no effects cause it to disappear? Is your app using routes and modules?
Thanks so muth! The problem has been solved, Because it belongs to different scenes,So when I update the main scene, I also update the scene where it is, and the problem is solved。
<ng-container ngIf="true"> <ngt-soba-gizmo-helper name="GizmoHelperViewCube" ngIf="mode === 'viewcube'" [alignment]="alignment" [margin]="margin" [scale]="0.75" (ready)="ready.emit($event)"> <ngt-soba-gizmo-viewcube font="4rem Inter var, Arial, sans-serif" [faces]="['右', '左', '上', '下', '前', '后']" [opacity]="0.8" color="#00c8d6" strokeColor="#00b0bd" textColor="black" hoverColor="#00b0bd"> <ngt-soba-gizmo-helper name="GizmoHelperViewPort" *ngIf="mode === 'viewport'" [alignment]="alignment" [margin]="margin" (ready)="ready.emit($event)"> <ngt-soba-gizmo-viewport [axisColors]="['red', 'green', 'blue']" labelColor="black" [hideNegativeAxes]="false">
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; import { Camera, Color, Scene } from 'three'; import { Editor, EditorService } from '../../editor';
@Component({
selector: 'sm-gizmo-helper',
templateUrl: './gizmo-helper.component.html',
styleUrls: ['./gizmo-helper.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class GizmoHelperComponent{
@Input() mode: 'viewport' | 'viewcube' = 'viewcube';
@Input() alignment:
| 'top-left'
| 'top-right'
| 'bottom-right'
| 'bottom-left' = 'top-right';
@Input() margin: [number, number] = [80, 80];
@Output() ready = new EventEmitter
editor!:Editor; constructor(private editorService:EditorService){ }
ngAfterViewInit(): void { this.editorService.getEditor().subscribe(editor=>{ editor.scene.onAfterRender = function(){ const gizmoScene = editor.gizmoHelper.parent; if(gizmoScene && gizmoScene instanceof Scene){ const camera = gizmoScene.children.find(o=>o instanceof Camera); if(camera && camera instanceof Camera){ editor.renderer.render(gizmoScene,camera); } } } }) }
}
I have another question to ask,When I use the ngt-shadow-material like below,I didn't get the shodow。 <ngt-canvas id="ngtcanvas" [shadows]="true" [gl]="{ alpha: true, antialias: true,logarithmicDepthBuffer: true}" [camera]="{position: [-500,500,500],far:200000, fov: 750}" (mousedown)="mousedown($event)" (mouseup)="mouseup($event)" (mousemove)="mousemove($event)" (created)="onCreated($event)"> <ngt-grid-helper [args]="[size, size/segment, axisColor, color]" (ready)="object = $event"> <ngt-mesh [rotation]='[-0.5|pi, 0, 0]' [visible]="true" [receiveShadow]="true" (click)="click.emit($event.point)"> <ngt-plane-geometry [args]="[size,size]"> <ngt-shadow-material [parameters]="{color:'#171717'}">
<ngt-ambient-light name="AmbientLight" [intensity]="0.8" [args]="['#505050',2]" (ready)="ready.emit($event)"></ngt-ambient-light>
<ngt-directional-light
name="DirectionalLight"
[position]="[0, 600, 1000]"
[args]="['#ffffff', 2]"
[castShadow]="true"
[shadow]="{ mapSize: [10000, 10000] | vector2 }"
(ready)="ready.emit($event)">
</ngt-directional-light>
<ngt-soba-loader *ngIf="false">
Do you mean the gizmo doesn't cast a shadow on the shadow material or any mesh in general doesn't cast a shadow on the shadow material?
any mesh
@yywf77 ShadowMaterial
does not determine whether to show shadows of your mesh or not. You'd need to use castShadow
and/or receiveShadow
on the Mesh/Light. ShadowMaterial
is just a transparent material but can reflect shadows (if they're casted on it), usually used for Floor.
NgtGizmoHelper disappear when resetting scene background or used NgtEffectComposer.