@@ -42,16 +42,16 @@ declare global {
42
42
template : `
43
43
<ngt-group ngtCompound [ref]="contactShadowsRef" [rotation]="[Math.PI / 2, 0, 0]">
44
44
<ngt-mesh
45
- [renderOrder]="shadowRenderOrder()"
45
+ [renderOrder]="shadowRenderOrder() ?? 0 "
46
46
[geometry]="contactShadows().planeGeometry"
47
47
[scale]="[1, -1, 1]"
48
48
[rotation]="[-Math.PI / 2, 0, 0]"
49
49
>
50
50
<ngt-mesh-basic-material
51
51
[map]="contactShadows().renderTarget.texture"
52
52
[transparent]="true"
53
- [opacity]="shadowOpacity()"
54
- [depthWrite]="shadowDepthWrite()"
53
+ [opacity]="shadowOpacity() ?? 1 "
54
+ [depthWrite]="shadowDepthWrite() ?? false "
55
55
>
56
56
<ngt-value [rawValue]="encoding()" attach="map.encoding" />
57
57
</ngt-mesh-basic-material>
@@ -127,11 +127,11 @@ export class NgtsContactShadows extends NgtSignalStore<NgtsContactShadowsState>
127
127
128
128
readonly #scaledWidth = computed ( ( ) => {
129
129
const scale = this . #scale( ) ;
130
- return this . #width( ) * ( Array . isArray ( scale ) ? scale [ 0 ] : scale || 1 ) ;
130
+ return ( this . #width( ) || 1 ) * ( Array . isArray ( scale ) ? scale [ 0 ] : scale || 1 ) ;
131
131
} ) ;
132
132
readonly #scaledHeight = computed ( ( ) => {
133
133
const scale = this . #scale( ) ;
134
- return this . #height( ) * ( Array . isArray ( scale ) ? scale [ 1 ] : scale || 1 ) ;
134
+ return ( this . #height( ) || 1 ) * ( Array . isArray ( scale ) ? scale [ 1 ] : scale || 1 ) ;
135
135
} ) ;
136
136
137
137
readonly encoding = this . #store. select ( 'gl' , 'outputEncoding' ) ;
@@ -145,9 +145,10 @@ export class NgtsContactShadows extends NgtSignalStore<NgtsContactShadowsState>
145
145
return [ - width / 2 , width / 2 , height / 2 , - height / 2 , 0 , this . #far( ) ] ;
146
146
} ) ;
147
147
readonly contactShadows = computed ( ( ) => {
148
- const color = this . #color( ) ;
149
- const renderTarget = new THREE . WebGLRenderTarget ( this . #resolution( ) , this . #resolution( ) ) ;
150
- const renderTargetBlur = new THREE . WebGLRenderTarget ( this . #resolution( ) , this . #resolution( ) ) ;
148
+ const color = this . #color( ) || '#000000' ;
149
+ const resolution = this . #resolution( ) || 512 ;
150
+ const renderTarget = new THREE . WebGLRenderTarget ( resolution , resolution ) ;
151
+ const renderTargetBlur = new THREE . WebGLRenderTarget ( resolution , resolution ) ;
151
152
renderTargetBlur . texture . generateMipmaps = renderTarget . texture . generateMipmaps = false ;
152
153
const planeGeometry = new THREE . PlaneGeometry ( this . #scaledWidth( ) , this . #scaledHeight( ) ) . rotateX ( Math . PI / 2 ) ;
153
154
const blurPlane = new Mesh ( planeGeometry ) ;
@@ -205,7 +206,7 @@ export class NgtsContactShadows extends NgtSignalStore<NgtsContactShadowsState>
205
206
}
206
207
207
208
#onBeforeRender( count : number , { scene, gl } : NgtRenderState ) {
208
- const { frames, blur, smooth } = this . get ( ) ;
209
+ const { frames = Infinity , blur = 1 , smooth = true } = this . get ( ) ;
209
210
const { depthMaterial, renderTarget } = this . contactShadows ( ) ;
210
211
const shadowCamera = this . shadowCameraRef . nativeElement ;
211
212
if ( shadowCamera && ( frames === Infinity || count < frames ) ) {
0 commit comments