Skip to content

Commit 72fef8c

Browse files
committed
fix(soba): use texture params for progressive light maps
1 parent 5a9ec1e commit 72fef8c

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

libs/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ export * from './lib/utils/make';
2424
export * from './lib/utils/safe-detect-changes';
2525
export * from './lib/utils/signal-store';
2626
export * from './lib/utils/update';
27+
import './lib/three-types';
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { Injector, assertInInjectionContext, inject } from '@angular/core';
22

33
export function assertInjectionContext(fn: Function, injector?: Injector): Injector {
4-
try {
5-
if (!injector) {
6-
return inject(Injector);
7-
}
8-
return injector;
9-
} catch {
10-
!injector && assertInInjectionContext(fn);
11-
return null!;
12-
}
4+
!injector && assertInInjectionContext(fn);
5+
return injector ?? inject(Injector);
136
}

libs/soba/src/misc/animations.stories.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgIf } from '@angular/common';
1+
import { NgIf, NgTemplateOutlet } from '@angular/common';
22
import { CUSTOM_ELEMENTS_SCHEMA, Component, Input, effect, signal, type Signal } from '@angular/core';
33
import { NgtArgs } from 'angular-three';
44
import { injectNgtsGLTFLoader, type NgtsGLTF } from 'angular-three-soba/loaders';
@@ -24,16 +24,18 @@ type YBotGLTF = NgtsGLTF<{
2424
<ngt-group *ngIf="yBotGltf() as yBot" [dispose]="null" [position]="[0, -1, 0]" [ref]="animations.ref">
2525
<ngt-group [rotation]="[Math.PI / 2, 0, 0]" [scale]="0.01">
2626
<ngt-primitive *args="[yBot.nodes.mixamorigHips]" />
27-
<ngt-skinned-mesh [geometry]="yBot.nodes.YB_Body.geometry" [skeleton]="yBot.nodes.YB_Body.skeleton">
28-
<ngt-mesh-matcap-material [matcap]="matcapBody.texture()" [skinning]="true" />
29-
</ngt-skinned-mesh>
30-
<ngt-skinned-mesh [geometry]="yBot.nodes.YB_Joints.geometry" [skeleton]="yBot.nodes.YB_Joints.skeleton">
31-
<ngt-mesh-matcap-material [matcap]="matcapJoints.texture()" [skinning]="true" />
32-
</ngt-skinned-mesh>
27+
<ng-container *ngTemplateOutlet="skin; context: { matcap: matcapBody, yb: yBot.nodes.YB_Body }" />
28+
<ng-container *ngTemplateOutlet="skin; context: { matcap: matcapJoints, yb: yBot.nodes.YB_Joints }" />
3329
</ngt-group>
3430
</ngt-group>
31+
32+
<ng-template #skin let-matcap="matcap" let-yb="yb">
33+
<ngt-skinned-mesh [geometry]="yb.geometry" [skeleton]="yb.skeleton">
34+
<ngt-mesh-matcap-material [matcap]="matcap.texture()" [skinning]="true" />
35+
</ngt-skinned-mesh>
36+
</ng-template>
3537
`,
36-
imports: [NgtArgs, NgIf],
38+
imports: [NgtArgs, NgIf, NgTemplateOutlet],
3739
schemas: [CUSTOM_ELEMENTS_SCHEMA],
3840
})
3941
class DefaultAnimationsStory {

libs/soba/staging/src/accumulative-shadows/progressive-light-map.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ export class ProgressiveLightMap {
3939
this.clearAlpha = 0;
4040

4141
// Create the Progressive LightMap Texture
42-
const format = /(Android|iPad|iPhone|iPod)/g.test(navigator.userAgent) ? THREE.HalfFloatType : THREE.FloatType;
43-
this.progressiveLightMap1 = new THREE.WebGLRenderTarget(this.res, this.res, {
44-
type: format,
45-
});
46-
this.progressiveLightMap2 = new THREE.WebGLRenderTarget(this.res, this.res, {
47-
type: format,
48-
});
42+
const textureParams = {
43+
type: THREE.HalfFloatType,
44+
magFilter: THREE.NearestFilter,
45+
minFilter: THREE.NearestFilter,
46+
};
47+
this.progressiveLightMap1 = new THREE.WebGLRenderTarget(this.res, this.res, textureParams);
48+
this.progressiveLightMap2 = new THREE.WebGLRenderTarget(this.res, this.res, textureParams);
4949

5050
// Inject some spicy new logic into a standard phong material
5151
this.discardMat = new DiscardMaterial();

0 commit comments

Comments
 (0)