Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5758b6d

Browse files
committed
docs: adjust porsche example to hide shadows
1 parent 1cc65c3 commit 5758b6d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

apps/kitchen-sink/src/app/soba/porsche/model.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1+
import { NgTemplateOutlet } from '@angular/common';
12
import { ChangeDetectionStrategy, Component, computed, CUSTOM_ELEMENTS_SCHEMA, effect, input } from '@angular/core';
23
import { applyProps, NgtArgs } from 'angular-three';
34
import { injectGLTF } from 'angular-three-soba/loaders';
45
import { Mesh } from 'three';
56
import { color } from './color';
67

78
@Component({
8-
selector: 'app-porsche',
9+
selector: 'app-porsche-model',
910
standalone: true,
1011
template: `
1112
<ngt-primitive *args="[model()]" [parameters]="{ position: position(), rotation: rotation(), scale: scale() }" />
1213
`,
1314
schemas: [CUSTOM_ELEMENTS_SCHEMA],
1415
changeDetection: ChangeDetectionStrategy.OnPush,
15-
imports: [NgtArgs],
16+
imports: [NgtArgs, NgTemplateOutlet],
1617
})
1718
export class Model {
1819
position = input([0, 0, 0]);
1920
rotation = input([0, 0, 0]);
2021
scale = input(1);
2122

22-
private gltf = injectGLTF(() => './911-transformed.glb');
23+
gltf = injectGLTF(() => './911-transformed.glb');
2324
protected model = computed(() => {
2425
const gltf = this.gltf();
2526
if (!gltf) return null;
27+
2628
const { scene, nodes, materials } = gltf;
2729

2830
Object.values(nodes).forEach((node) => {

apps/kitchen-sink/src/app/soba/porsche/porsche.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
22
import { injectBeforeRender, NgtCanvas } from 'angular-three';
3+
import { injectGLTF } from 'angular-three-soba/loaders';
34
import { NgtsAccumulativeShadows, NgtsEnvironment, NgtsRandomizedLights } from 'angular-three-soba/staging';
45
import { Vector3 } from 'three';
56
import { color, colorAsHex } from './color';
67
import { Lightformers } from './lightformers';
78
import { Model } from './model';
89

10+
injectGLTF.preload(() => './911-transformed.glb');
11+
912
@Component({
1013
standalone: true,
1114
template: `
@@ -21,16 +24,20 @@ import { Model } from './model';
2124
</ngt-spot-light>
2225
<ngt-ambient-light [intensity]="0.5 * Math.PI" />
2326
24-
<app-porsche [position]="[-0.5, -0.18, 0]" [rotation]="[0, Math.PI / 5, 0]" [scale]="1.6" />
27+
<app-porsche-model #model [position]="[-0.5, -0.18, 0]" [rotation]="[0, Math.PI / 5, 0]" [scale]="1.6" />
2528
26-
<ngts-accumulative-shadows [options]="{ position: [0, -1.16, 0], frames: 100, alphaTest: 0.9, scale: 10 }">
29+
<ngts-accumulative-shadows
30+
[options]="{ position: [0, -1.16, 0], frames: 100, alphaTest: 0.9, scale: 10, visible: !!model.gltf() }"
31+
>
2732
<ngts-randomized-lights
2833
[options]="{ amount: 8, radius: 10, ambient: 0.5, position: [1, 5, -1], intensity: 1.5 * Math.PI }"
2934
/>
3035
</ngts-accumulative-shadows>
3136
3237
<ngts-environment [options]="{ background: true, blur: 1, resolution: 256, frames: Infinity }">
33-
<app-lightformers * />
38+
<ng-template>
39+
<app-lightformers />
40+
</ng-template>
3441
</ngts-environment>
3542
`,
3643
schemas: [CUSTOM_ELEMENTS_SCHEMA],

0 commit comments

Comments
 (0)