angular-three-soba 1.8.1 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/assets/default-spot-light-shadow.glsl +10 -0
  2. package/esm2020/misc/index.mjs +2 -1
  3. package/esm2020/misc/lib/depth-buffer/depth-buffer.mjs +39 -0
  4. package/esm2020/shaders/index.mjs +2 -1
  5. package/esm2020/shaders/lib/mesh-distort-material/mesh-distort-material.mjs +3 -3
  6. package/esm2020/shaders/lib/spot-light-material/spot-light-material.mjs +86 -0
  7. package/esm2020/staging/index.mjs +3 -1
  8. package/esm2020/staging/lib/spot-light/common.mjs +40 -0
  9. package/esm2020/staging/lib/spot-light/shadow-mesh-input.mjs +46 -0
  10. package/esm2020/staging/lib/spot-light/spot-light-input.mjs +61 -0
  11. package/esm2020/staging/lib/spot-light/spot-light-shadow-no-shader.mjs +73 -0
  12. package/esm2020/staging/lib/spot-light/spot-light-shadow-shader.mjs +124 -0
  13. package/esm2020/staging/lib/spot-light/spot-light-shadow.mjs +63 -0
  14. package/esm2020/staging/lib/spot-light/spot-light.mjs +116 -0
  15. package/esm2020/staging/lib/spot-light/volumetric-mesh.mjs +85 -0
  16. package/fesm2015/angular-three-soba-misc.mjs +38 -4
  17. package/fesm2015/angular-three-soba-misc.mjs.map +1 -1
  18. package/fesm2015/angular-three-soba-shaders.mjs +89 -4
  19. package/fesm2015/angular-three-soba-shaders.mjs.map +1 -1
  20. package/fesm2015/angular-three-soba-staging.mjs +564 -5
  21. package/fesm2015/angular-three-soba-staging.mjs.map +1 -1
  22. package/fesm2020/angular-three-soba-misc.mjs +37 -3
  23. package/fesm2020/angular-three-soba-misc.mjs.map +1 -1
  24. package/fesm2020/angular-three-soba-shaders.mjs +89 -4
  25. package/fesm2020/angular-three-soba-shaders.mjs.map +1 -1
  26. package/fesm2020/angular-three-soba-staging.mjs +564 -5
  27. package/fesm2020/angular-three-soba-staging.mjs.map +1 -1
  28. package/misc/index.d.ts +1 -0
  29. package/misc/lib/depth-buffer/depth-buffer.d.ts +7 -0
  30. package/package.json +1 -1
  31. package/plugin/package.json +1 -1
  32. package/shaders/index.d.ts +1 -0
  33. package/shaders/lib/mesh-distort-material/mesh-distort-material.d.ts +7 -1
  34. package/shaders/lib/spot-light-material/spot-light-material.d.ts +4 -0
  35. package/staging/index.d.ts +2 -0
  36. package/staging/lib/spot-light/common.d.ts +3 -0
  37. package/staging/lib/spot-light/shadow-mesh-input.d.ts +13 -0
  38. package/staging/lib/spot-light/spot-light-input.d.ts +16 -0
  39. package/staging/lib/spot-light/spot-light-shadow-no-shader.d.ts +14 -0
  40. package/staging/lib/spot-light/spot-light-shadow-shader.d.ts +25 -0
  41. package/staging/lib/spot-light/spot-light-shadow.d.ts +6 -0
  42. package/staging/lib/spot-light/spot-light.d.ts +17 -0
  43. package/staging/lib/spot-light/volumetric-mesh.d.ts +15 -0
@@ -1,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, inject, Directive, Component, CUSTOM_ELEMENTS_SCHEMA, Input, EventEmitter, Output, TemplateRef, ContentChild, ChangeDetectorRef } from '@angular/core';
3
- import { extend, NgtStore, getLocalState, NgtRxStore, injectNgtRef, NgtArgs, NgtRepeat, is, injectBeforeRender, NgtPush, injectNgtDestroy, injectNgtLoader, startWithUndefined, prepare, NgtPortal, NgtPortalContent } from 'angular-three';
4
- import { shaderMaterial } from 'angular-three-soba/shaders';
3
+ import { extend, NgtStore, getLocalState, NgtRxStore, injectNgtRef, NgtArgs, NgtRepeat, is, injectBeforeRender, NgtPush, injectNgtDestroy, injectNgtLoader, startWithUndefined, prepare, NgtPortal, NgtPortalContent, createRunInContext, checkUpdate } from 'angular-three';
4
+ import { shaderMaterial, SpotLightMaterial } from 'angular-three-soba/shaders';
5
5
  import { Subject, combineLatest, switchMap, isObservable, of, debounceTime, map, takeUntil, startWith, withLatestFrom } from 'rxjs';
6
6
  import * as THREE from 'three';
7
- import { Group, Mesh, PlaneGeometry, DirectionalLight, OrthographicCamera, Vector2, Box3, Vector3, Sphere, MeshStandardMaterial, MeshBasicMaterial, CubeTextureLoader, CubeReflectionMapping, EquirectangularReflectionMapping, sRGBEncoding, LinearEncoding, CubeCamera, HalfFloatType, Points, BufferGeometry, BufferAttribute, Vector4, Color, MathUtils, AmbientLight, SpotLight, PointLight, Spherical, AdditiveBlending } from 'three';
8
- import { SimplexNoise, HorizontalBlurShader, VerticalBlurShader, RGBELoader, GroundProjectedEnv, Sky } from 'three-stdlib';
7
+ import { Group, Mesh, PlaneGeometry, DirectionalLight, OrthographicCamera, Vector2, Box3, Vector3, Sphere, MeshStandardMaterial, MeshBasicMaterial, CubeTextureLoader, CubeReflectionMapping, EquirectangularReflectionMapping, sRGBEncoding, LinearEncoding, CubeCamera, HalfFloatType, Points, BufferGeometry, BufferAttribute, Vector4, Color, MathUtils, SpotLight, SpotLightHelper, AmbientLight, PointLight, Spherical, AdditiveBlending } from 'three';
8
+ import { SimplexNoise, HorizontalBlurShader, VerticalBlurShader, RGBELoader, GroundProjectedEnv, Sky, FullScreenQuad } from 'three-stdlib';
9
9
  import { NgFor, NgIf, NgTemplateOutlet } from '@angular/common';
10
10
  import { NgtsBillboard } from 'angular-three-soba/abstractions';
11
11
  import { injectNgtsTextureLoader } from 'angular-three-soba/loaders';
@@ -2395,6 +2395,565 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2395
2395
  type: Input
2396
2396
  }] } });
2397
2397
 
2398
+ class NgtsSpotLightInput extends NgtRxStore {
2399
+ set depthBuffer(depthBuffer) {
2400
+ this.set({ depthBuffer });
2401
+ }
2402
+ set angle(angle) {
2403
+ this.set({ angle });
2404
+ }
2405
+ set distance(distance) {
2406
+ this.set({ distance });
2407
+ }
2408
+ set attenuation(attenuation) {
2409
+ this.set({ attenuation });
2410
+ }
2411
+ set anglePower(anglePower) {
2412
+ this.set({ anglePower });
2413
+ }
2414
+ set radiusTop(radiusTop) {
2415
+ this.set({ radiusTop });
2416
+ }
2417
+ set radiusBottom(radiusBottom) {
2418
+ this.set({ radiusBottom });
2419
+ }
2420
+ set opacity(opacity) {
2421
+ this.set({ opacity });
2422
+ }
2423
+ set color(color) {
2424
+ this.set({ color });
2425
+ }
2426
+ set debug(debug) {
2427
+ this.set({ debug });
2428
+ }
2429
+ }
2430
+ NgtsSpotLightInput.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightInput, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2431
+ NgtsSpotLightInput.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.4", type: NgtsSpotLightInput, inputs: { depthBuffer: "depthBuffer", angle: "angle", distance: "distance", attenuation: "attenuation", anglePower: "anglePower", radiusTop: "radiusTop", radiusBottom: "radiusBottom", opacity: "opacity", color: "color", debug: "debug" }, usesInheritance: true, ngImport: i0 });
2432
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightInput, decorators: [{
2433
+ type: Directive
2434
+ }], propDecorators: { depthBuffer: [{
2435
+ type: Input
2436
+ }], angle: [{
2437
+ type: Input
2438
+ }], distance: [{
2439
+ type: Input
2440
+ }], attenuation: [{
2441
+ type: Input
2442
+ }], anglePower: [{
2443
+ type: Input
2444
+ }], radiusTop: [{
2445
+ type: Input
2446
+ }], radiusBottom: [{
2447
+ type: Input
2448
+ }], opacity: [{
2449
+ type: Input
2450
+ }], color: [{
2451
+ type: Input
2452
+ }], debug: [{
2453
+ type: Input
2454
+ }] } });
2455
+
2456
+ extend({ Mesh });
2457
+ class NgtsVolumetricMesh extends NgtsSpotLightInput {
2458
+ initialize() {
2459
+ super.initialize();
2460
+ this.set({ opacity: 1, color: 'white', distance: 5, angle: 0.15, attenuation: 5, anglePower: 5 });
2461
+ }
2462
+ constructor() {
2463
+ super();
2464
+ this.mesh = injectNgtRef();
2465
+ this.material = new SpotLightMaterial();
2466
+ this.nullRaycast = () => null;
2467
+ this.vec = new THREE.Vector3();
2468
+ this.store = inject(NgtStore);
2469
+ this.connect('normalizedRadiusTop', this.select('radiusTop').pipe(startWithUndefined(), map((radiusTop) => (radiusTop === undefined ? 0.1 : radiusTop))));
2470
+ this.connect('normalizedRadiusBottom', combineLatest([this.select('radiusBottom').pipe(startWithUndefined()), this.select('angle')]).pipe(map(([radiusBottom, angle]) => (radiusBottom === undefined ? angle * 7 : radiusBottom))));
2471
+ this.connect('geometry', combineLatest([
2472
+ this.select('normalizedRadiusTop'),
2473
+ this.select('normalizedRadiusBottom'),
2474
+ this.select('distance'),
2475
+ ]).pipe(map(([radiusTop, radiusBottom, distance]) => {
2476
+ const geometry = new THREE.CylinderGeometry(radiusTop, radiusBottom, distance, 128, 64, true);
2477
+ geometry.applyMatrix4(new THREE.Matrix4().makeTranslation(0, -distance / 2, 0));
2478
+ geometry.applyMatrix4(new THREE.Matrix4().makeRotationX(-Math.PI / 2));
2479
+ return geometry;
2480
+ })));
2481
+ this.connect('cameraNear', this.store.select('camera').pipe(map((camera) => camera.near)));
2482
+ this.connect('cameraFar', this.store.select('camera').pipe(map((camera) => camera.far)));
2483
+ this.connect('resolution', combineLatest([
2484
+ this.select('depthBuffer').pipe(startWithUndefined()),
2485
+ this.store.select('size'),
2486
+ this.store.select('viewport', 'dpr'),
2487
+ ]).pipe(map(([depthBuffer, size, dpr]) => (depthBuffer ? [size.width * dpr, size.height * dpr] : [0, 0]))));
2488
+ injectBeforeRender(() => {
2489
+ this.material.uniforms['spotPosition'].value.copy(this.mesh.nativeElement.getWorldPosition(this.vec));
2490
+ this.mesh.nativeElement.lookAt(this.mesh.nativeElement.parent.target.getWorldPosition(this.vec));
2491
+ });
2492
+ }
2493
+ }
2494
+ NgtsVolumetricMesh.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsVolumetricMesh, deps: [], target: i0.ɵɵFactoryTarget.Component });
2495
+ NgtsVolumetricMesh.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgtsVolumetricMesh, isStandalone: true, selector: "ngts-volumetric-mesh", usesInheritance: true, ngImport: i0, template: `
2496
+ <ngt-mesh [ref]="mesh" [geometry]="get('geometry')" [raycast]="nullRaycast">
2497
+ <ngt-primitive *args="[material]" attach="material">
2498
+ <ngt-value [rawValue]="get('opacity')" attach="uniforms.opacity.value" />
2499
+ <ngt-value [rawValue]="get('color')" attach="uniforms.lightColor.value" />
2500
+ <ngt-value [rawValue]="get('attenuation')" attach="uniforms.attenuation.value" />
2501
+ <ngt-value [rawValue]="get('anglePower')" attach="uniforms.anglePower.value" />
2502
+ <ngt-value [rawvalue]="get('depthBuffer')" attach="uniforms.depth.value" />
2503
+ <ngt-value [rawvalue]="get('cameraNear')" attach="uniforms.cameraNear.value" />
2504
+ <ngt-value [rawvalue]="get('cameraFar')" attach="uniforms.cameraFar.value" />
2505
+ <ngt-value [rawvalue]="get('resolution')" attach="uniforms.resolution.value" />
2506
+ </ngt-primitive>
2507
+ </ngt-mesh>
2508
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
2509
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsVolumetricMesh, decorators: [{
2510
+ type: Component,
2511
+ args: [{
2512
+ selector: 'ngts-volumetric-mesh',
2513
+ standalone: true,
2514
+ template: `
2515
+ <ngt-mesh [ref]="mesh" [geometry]="get('geometry')" [raycast]="nullRaycast">
2516
+ <ngt-primitive *args="[material]" attach="material">
2517
+ <ngt-value [rawValue]="get('opacity')" attach="uniforms.opacity.value" />
2518
+ <ngt-value [rawValue]="get('color')" attach="uniforms.lightColor.value" />
2519
+ <ngt-value [rawValue]="get('attenuation')" attach="uniforms.attenuation.value" />
2520
+ <ngt-value [rawValue]="get('anglePower')" attach="uniforms.anglePower.value" />
2521
+ <ngt-value [rawvalue]="get('depthBuffer')" attach="uniforms.depth.value" />
2522
+ <ngt-value [rawvalue]="get('cameraNear')" attach="uniforms.cameraNear.value" />
2523
+ <ngt-value [rawvalue]="get('cameraFar')" attach="uniforms.cameraFar.value" />
2524
+ <ngt-value [rawvalue]="get('resolution')" attach="uniforms.resolution.value" />
2525
+ </ngt-primitive>
2526
+ </ngt-mesh>
2527
+ `,
2528
+ imports: [NgtArgs],
2529
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2530
+ }]
2531
+ }], ctorParameters: function () { return []; } });
2532
+
2533
+ extend({ SpotLight, SpotLightHelper, Group });
2534
+ const NGTS_SPOT_LIGHT_API = new InjectionToken('NgtsSpotLight API');
2535
+ function spotLightApiFactory(spotLight) {
2536
+ const api = {
2537
+ spotLight: spotLight.spotLightRef,
2538
+ };
2539
+ Object.defineProperty(api, 'debug', {
2540
+ get: () => spotLight.get('debug'),
2541
+ });
2542
+ return api;
2543
+ }
2544
+ class NgtsSpotLight extends NgtsSpotLightInput {
2545
+ constructor() {
2546
+ super(...arguments);
2547
+ this.spotLightRef = injectNgtRef();
2548
+ }
2549
+ set volumetric(volumetric) {
2550
+ this.set({ volumetric });
2551
+ }
2552
+ initialize() {
2553
+ super.initialize();
2554
+ this.set({
2555
+ opacity: 1,
2556
+ color: 'white',
2557
+ distance: 5,
2558
+ angle: 0.15,
2559
+ attenuation: 5,
2560
+ anglePower: 5,
2561
+ volumetric: true,
2562
+ debug: false,
2563
+ });
2564
+ }
2565
+ }
2566
+ NgtsSpotLight.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLight, deps: null, target: i0.ɵɵFactoryTarget.Component });
2567
+ NgtsSpotLight.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgtsSpotLight, isStandalone: true, selector: "ngts-spot-light", inputs: { spotLightRef: "spotLightRef", volumetric: "volumetric" }, providers: [{ provide: NGTS_SPOT_LIGHT_API, useFactory: spotLightApiFactory, deps: [NgtsSpotLight] }], usesInheritance: true, ngImport: i0, template: `
2568
+ <ngt-group>
2569
+ <ng-container *ngIf="get('debug') && spotLightRef.nativeElement">
2570
+ <ngt-spot-light-helper *args="[spotLightRef.nativeElement]" />
2571
+ </ng-container>
2572
+ <ngt-spot-light
2573
+ [ref]="spotLightRef"
2574
+ [color]="get('color')"
2575
+ [distance]="get('distance')"
2576
+ [angle]="get('angle')"
2577
+ [castShadow]="true"
2578
+ ngtCompound
2579
+ >
2580
+ <ngts-volumetric-mesh
2581
+ *ngIf="get('volumetric')"
2582
+ [debug]="get('debug')"
2583
+ [opacity]="get('opacity')"
2584
+ [radiusTop]="get('radiusTop')"
2585
+ [radiusBottom]="get('radiusBottom')"
2586
+ [depthBuffer]="get('depthBuffer')"
2587
+ [color]="get('color')"
2588
+ [distance]="get('distance')"
2589
+ [angle]="get('angle')"
2590
+ [attenuation]="get('attenuation')"
2591
+ [anglePower]="get('anglePower')"
2592
+ />
2593
+ </ngt-spot-light>
2594
+ <ng-content />
2595
+ </ngt-group>
2596
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }, { kind: "component", type: NgtsVolumetricMesh, selector: "ngts-volumetric-mesh" }] });
2597
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLight, decorators: [{
2598
+ type: Component,
2599
+ args: [{
2600
+ selector: 'ngts-spot-light',
2601
+ standalone: true,
2602
+ template: `
2603
+ <ngt-group>
2604
+ <ng-container *ngIf="get('debug') && spotLightRef.nativeElement">
2605
+ <ngt-spot-light-helper *args="[spotLightRef.nativeElement]" />
2606
+ </ng-container>
2607
+ <ngt-spot-light
2608
+ [ref]="spotLightRef"
2609
+ [color]="get('color')"
2610
+ [distance]="get('distance')"
2611
+ [angle]="get('angle')"
2612
+ [castShadow]="true"
2613
+ ngtCompound
2614
+ >
2615
+ <ngts-volumetric-mesh
2616
+ *ngIf="get('volumetric')"
2617
+ [debug]="get('debug')"
2618
+ [opacity]="get('opacity')"
2619
+ [radiusTop]="get('radiusTop')"
2620
+ [radiusBottom]="get('radiusBottom')"
2621
+ [depthBuffer]="get('depthBuffer')"
2622
+ [color]="get('color')"
2623
+ [distance]="get('distance')"
2624
+ [angle]="get('angle')"
2625
+ [attenuation]="get('attenuation')"
2626
+ [anglePower]="get('anglePower')"
2627
+ />
2628
+ </ngt-spot-light>
2629
+ <ng-content />
2630
+ </ngt-group>
2631
+ `,
2632
+ imports: [NgIf, NgtArgs, NgtsVolumetricMesh],
2633
+ providers: [{ provide: NGTS_SPOT_LIGHT_API, useFactory: spotLightApiFactory, deps: [NgtsSpotLight] }],
2634
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2635
+ }]
2636
+ }], propDecorators: { spotLightRef: [{
2637
+ type: Input
2638
+ }], volumetric: [{
2639
+ type: Input
2640
+ }] } });
2641
+
2642
+ class NgtsSpotLightShadowMeshInput extends NgtRxStore {
2643
+ set distance(distance) {
2644
+ this.set({ distance });
2645
+ }
2646
+ set alphaTest(alphaTest) {
2647
+ this.set({ alphaTest });
2648
+ }
2649
+ set scale(scale) {
2650
+ this.set({ scale });
2651
+ }
2652
+ set map(map) {
2653
+ this.set({ map });
2654
+ }
2655
+ set shader(shader) {
2656
+ this.set({ shader });
2657
+ }
2658
+ set width(width) {
2659
+ this.set({ width });
2660
+ }
2661
+ set height(height) {
2662
+ this.set({ height });
2663
+ }
2664
+ }
2665
+ NgtsSpotLightShadowMeshInput.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowMeshInput, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2666
+ NgtsSpotLightShadowMeshInput.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.4", type: NgtsSpotLightShadowMeshInput, inputs: { distance: "distance", alphaTest: "alphaTest", scale: "scale", map: "map", shader: "shader", width: "width", height: "height" }, usesInheritance: true, ngImport: i0 });
2667
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowMeshInput, decorators: [{
2668
+ type: Directive
2669
+ }], propDecorators: { distance: [{
2670
+ type: Input
2671
+ }], alphaTest: [{
2672
+ type: Input
2673
+ }], scale: [{
2674
+ type: Input
2675
+ }], map: [{
2676
+ type: Input
2677
+ }], shader: [{
2678
+ type: Input
2679
+ }], width: [{
2680
+ type: Input
2681
+ }], height: [{
2682
+ type: Input
2683
+ }] } });
2684
+
2685
+ const isSpotLight = (child) => {
2686
+ return child === null || child === void 0 ? void 0 : child.isSpotLight;
2687
+ };
2688
+ function injectShadowMeshCommon(spotLight, mesh, width, height, distance) {
2689
+ const pos = new THREE.Vector3();
2690
+ const dir = new THREE.Vector3();
2691
+ const commonEffect = (instance) => {
2692
+ instance.hold(combineLatest([
2693
+ spotLight.$,
2694
+ instance.select('width').pipe(startWith(width)),
2695
+ instance.select('height').pipe(startWith(height)),
2696
+ ]), ([light, width, height]) => {
2697
+ if (isSpotLight(light)) {
2698
+ console.log('[NGTS] SpotLight instance -->', light);
2699
+ light.shadow.mapSize.set(width, height);
2700
+ light.shadow.needsUpdate = true;
2701
+ }
2702
+ else {
2703
+ throw new Error('<ngts-spot-light-shadow> must be a child of a <ngts-spot-light>');
2704
+ }
2705
+ });
2706
+ };
2707
+ injectBeforeRender(() => {
2708
+ if (!spotLight.nativeElement)
2709
+ return;
2710
+ const A = spotLight.nativeElement.position;
2711
+ const B = spotLight.nativeElement.target.position;
2712
+ dir.copy(B).sub(A);
2713
+ const len = dir.length();
2714
+ dir.normalize().multiplyScalar(len * distance);
2715
+ pos.copy(A).add(dir);
2716
+ mesh.nativeElement.position.copy(pos);
2717
+ mesh.nativeElement.lookAt(spotLight.nativeElement.target.position);
2718
+ });
2719
+ return commonEffect;
2720
+ }
2721
+
2722
+ extend({ Mesh, PlaneGeometry, MeshBasicMaterial });
2723
+ class NgtsSpotLightShadowNoShader extends NgtsSpotLightShadowMeshInput {
2724
+ constructor() {
2725
+ super(...arguments);
2726
+ this.mesh = injectNgtRef();
2727
+ this.spotLightApi = inject(NGTS_SPOT_LIGHT_API);
2728
+ this.DoubleSide = THREE.DoubleSide;
2729
+ this.runInContext = createRunInContext();
2730
+ }
2731
+ initialize() {
2732
+ super.initialize();
2733
+ this.set({ distance: 0.4, alphaTest: 0.5, width: 512, height: 512 });
2734
+ this.hold(this.select('map'), (map) => {
2735
+ if (map) {
2736
+ map.wrapS = map.wrapT = THREE.RepeatWrapping;
2737
+ checkUpdate(map);
2738
+ }
2739
+ });
2740
+ }
2741
+ ngOnInit() {
2742
+ const commonEffect = this.runInContext(() => {
2743
+ return injectShadowMeshCommon(this.spotLightApi.spotLight, this.mesh, this.get('width'), this.get('height'), this.get('distance'));
2744
+ });
2745
+ commonEffect(this);
2746
+ }
2747
+ }
2748
+ NgtsSpotLightShadowNoShader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowNoShader, deps: null, target: i0.ɵɵFactoryTarget.Component });
2749
+ NgtsSpotLightShadowNoShader.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgtsSpotLightShadowNoShader, isStandalone: true, selector: "ngts-spot-light-shadow-no-shader", usesInheritance: true, ngImport: i0, template: `
2750
+ <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
2751
+ <ngt-plane-geometry />
2752
+ <ngt-mesh-basic-material
2753
+ [transparent]="true"
2754
+ [side]="DoubleSide"
2755
+ [alphaTest]="get('alphaTest')"
2756
+ [alphaMap]="key$('map') | ngtPush"
2757
+ [opacity]="spotLightApi.debug ? 1 : 0"
2758
+ >
2759
+ <ng-content />
2760
+ </ngt-mesh-basic-material>
2761
+ </ngt-mesh>
2762
+ `, isInline: true, dependencies: [{ kind: "pipe", type: NgtPush, name: "ngtPush" }] });
2763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowNoShader, decorators: [{
2764
+ type: Component,
2765
+ args: [{
2766
+ selector: 'ngts-spot-light-shadow-no-shader',
2767
+ standalone: true,
2768
+ template: `
2769
+ <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
2770
+ <ngt-plane-geometry />
2771
+ <ngt-mesh-basic-material
2772
+ [transparent]="true"
2773
+ [side]="DoubleSide"
2774
+ [alphaTest]="get('alphaTest')"
2775
+ [alphaMap]="key$('map') | ngtPush"
2776
+ [opacity]="spotLightApi.debug ? 1 : 0"
2777
+ >
2778
+ <ng-content />
2779
+ </ngt-mesh-basic-material>
2780
+ </ngt-mesh>
2781
+ `,
2782
+ imports: [NgtPush],
2783
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2784
+ }]
2785
+ }] });
2786
+
2787
+ extend({ Mesh, PlaneGeometry, MeshBasicMaterial });
2788
+ class NgtsSpotLightShadowShader extends NgtsSpotLightShadowMeshInput {
2789
+ initialize() {
2790
+ super.initialize();
2791
+ this.set({ distance: 0.4, alphaTest: 0.5, width: 512, height: 512, scale: 1 });
2792
+ }
2793
+ constructor() {
2794
+ super();
2795
+ this.mesh = injectNgtRef();
2796
+ this.spotLightApi = inject(NGTS_SPOT_LIGHT_API);
2797
+ this.DoubleSide = THREE.DoubleSide;
2798
+ this.RepeatWrapping = THREE.RepeatWrapping;
2799
+ this.runInContext = createRunInContext();
2800
+ this.texture$ = this.select('renderTarget', 'texture');
2801
+ this.uniforms = {
2802
+ uShadowMap: { value: this.get('map') },
2803
+ uTime: { value: 0 },
2804
+ };
2805
+ this.connect('renderTarget', combineLatest([this.select('width'), this.select('height')]).pipe(map(([width, height]) => {
2806
+ return new THREE.WebGLRenderTarget(width, height, {
2807
+ format: THREE.RGBAFormat,
2808
+ encoding: THREE.LinearEncoding,
2809
+ stencilBuffer: false,
2810
+ // depthTexture: null!
2811
+ });
2812
+ })));
2813
+ this.connect('fsQuad', this.select('shader').pipe(map((shader) => {
2814
+ return new FullScreenQuad(new THREE.ShaderMaterial({
2815
+ uniforms: this.uniforms,
2816
+ vertexShader: /* glsl */ `
2817
+ varying vec2 vUv;
2818
+
2819
+ void main() {
2820
+ vUv = uv;
2821
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
2822
+ }
2823
+ `,
2824
+ fragmentShader: shader,
2825
+ }));
2826
+ })));
2827
+ this.hold(this.select('map'), (map) => {
2828
+ this.uniforms.uShadowMap.value = map;
2829
+ });
2830
+ this.effect(this.select('fsQuad'), (fsQuad) => {
2831
+ return () => {
2832
+ fsQuad.dispose();
2833
+ fsQuad.material.dispose();
2834
+ };
2835
+ });
2836
+ this.effect(this.select('renderTarget'), (renderTarget) => {
2837
+ return () => {
2838
+ renderTarget.dispose();
2839
+ };
2840
+ });
2841
+ injectBeforeRender(({ delta, gl }) => {
2842
+ this.uniforms.uTime.value += delta;
2843
+ const { fsQuad, renderTarget } = this.get();
2844
+ if (fsQuad && renderTarget) {
2845
+ gl.setRenderTarget(renderTarget);
2846
+ fsQuad.render(gl);
2847
+ gl.setRenderTarget(null);
2848
+ }
2849
+ });
2850
+ }
2851
+ ngOnInit() {
2852
+ const commonEffect = this.runInContext(() => {
2853
+ return injectShadowMeshCommon(this.spotLightApi.spotLight, this.mesh, this.get('width'), this.get('height'), this.get('distance'));
2854
+ });
2855
+ commonEffect(this);
2856
+ }
2857
+ }
2858
+ NgtsSpotLightShadowShader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowShader, deps: [], target: i0.ɵɵFactoryTarget.Component });
2859
+ NgtsSpotLightShadowShader.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgtsSpotLightShadowShader, isStandalone: true, selector: "ngts-spot-light-shadow-shader", usesInheritance: true, ngImport: i0, template: `
2860
+ <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
2861
+ <ngt-plane-geometry />
2862
+ <ngt-mesh-basic-material
2863
+ [transparent]="true"
2864
+ [side]="DoubleSide"
2865
+ [alphaTest]="get('alphaTest')"
2866
+ [alphaMap]="texture$ | ngtPush"
2867
+ [opacity]="spotLightApi.debug ? 1 : 0"
2868
+ >
2869
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapS" />
2870
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapT" />
2871
+ <ng-content />
2872
+ </ngt-mesh-basic-material>
2873
+ </ngt-mesh>
2874
+ `, isInline: true, dependencies: [{ kind: "pipe", type: NgtPush, name: "ngtPush" }] });
2875
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowShader, decorators: [{
2876
+ type: Component,
2877
+ args: [{
2878
+ selector: 'ngts-spot-light-shadow-shader',
2879
+ standalone: true,
2880
+ template: `
2881
+ <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
2882
+ <ngt-plane-geometry />
2883
+ <ngt-mesh-basic-material
2884
+ [transparent]="true"
2885
+ [side]="DoubleSide"
2886
+ [alphaTest]="get('alphaTest')"
2887
+ [alphaMap]="texture$ | ngtPush"
2888
+ [opacity]="spotLightApi.debug ? 1 : 0"
2889
+ >
2890
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapS" />
2891
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapT" />
2892
+ <ng-content />
2893
+ </ngt-mesh-basic-material>
2894
+ </ngt-mesh>
2895
+ `,
2896
+ imports: [NgtPush],
2897
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2898
+ }]
2899
+ }], ctorParameters: function () { return []; } });
2900
+
2901
+ class NgtsSpotLightShadow extends NgtsSpotLightShadowMeshInput {
2902
+ }
2903
+ NgtsSpotLightShadow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadow, deps: null, target: i0.ɵɵFactoryTarget.Component });
2904
+ NgtsSpotLightShadow.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgtsSpotLightShadow, isStandalone: true, selector: "ngts-spot-light-shadow", usesInheritance: true, ngImport: i0, template: `
2905
+ <ngts-spot-light-shadow-shader
2906
+ *ngIf="!!get('shader'); else noShader"
2907
+ [distance]="get('distance')"
2908
+ [shader]="get('shader')"
2909
+ [alphaTest]="get('alphaTest')"
2910
+ [scale]="get('scale')"
2911
+ [map]="get('map')"
2912
+ [width]="get('width')"
2913
+ [height]="get('height')"
2914
+ />
2915
+ <ng-template #noShader>
2916
+ <ngts-spot-light-shadow-no-shader
2917
+ [distance]="get('distance')"
2918
+ [alphaTest]="get('alphaTest')"
2919
+ [scale]="get('scale')"
2920
+ [map]="get('map')"
2921
+ [width]="get('width')"
2922
+ [height]="get('height')"
2923
+ />
2924
+ </ng-template>
2925
+ `, isInline: true, dependencies: [{ kind: "component", type: NgtsSpotLightShadowShader, selector: "ngts-spot-light-shadow-shader" }, { kind: "component", type: NgtsSpotLightShadowNoShader, selector: "ngts-spot-light-shadow-no-shader" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2926
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadow, decorators: [{
2927
+ type: Component,
2928
+ args: [{
2929
+ selector: 'ngts-spot-light-shadow',
2930
+ standalone: true,
2931
+ template: `
2932
+ <ngts-spot-light-shadow-shader
2933
+ *ngIf="!!get('shader'); else noShader"
2934
+ [distance]="get('distance')"
2935
+ [shader]="get('shader')"
2936
+ [alphaTest]="get('alphaTest')"
2937
+ [scale]="get('scale')"
2938
+ [map]="get('map')"
2939
+ [width]="get('width')"
2940
+ [height]="get('height')"
2941
+ />
2942
+ <ng-template #noShader>
2943
+ <ngts-spot-light-shadow-no-shader
2944
+ [distance]="get('distance')"
2945
+ [alphaTest]="get('alphaTest')"
2946
+ [scale]="get('scale')"
2947
+ [map]="get('map')"
2948
+ [width]="get('width')"
2949
+ [height]="get('height')"
2950
+ />
2951
+ </ng-template>
2952
+ `,
2953
+ imports: [NgtsSpotLightShadowShader, NgtsSpotLightShadowNoShader, NgIf, NgtPush],
2954
+ }]
2955
+ }] });
2956
+
2398
2957
  const presets = {
2399
2958
  rembrandt: {
2400
2959
  main: [1, 2, 1],
@@ -2912,5 +3471,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2912
3471
  * Generated bundle index. Do not edit.
2913
3472
  */
2914
3473
 
2915
- export { NGTS_BOUNDS_API, NgtsAccumulativeShadows, NgtsBounds, NgtsCameraShake, NgtsCenter, NgtsCloud, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentContent, NgtsFloat, NgtsRandomizedLights, NgtsSky, NgtsSparkles, NgtsStage, NgtsStageRefit, NgtsStars, calcPosFromAngles, ngtsEnvironmentPresetsObj };
3474
+ export { NGTS_BOUNDS_API, NGTS_SPOT_LIGHT_API, NgtsAccumulativeShadows, NgtsBounds, NgtsCameraShake, NgtsCenter, NgtsCloud, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentContent, NgtsFloat, NgtsRandomizedLights, NgtsSky, NgtsSparkles, NgtsSpotLight, NgtsSpotLightShadow, NgtsStage, NgtsStageRefit, NgtsStars, calcPosFromAngles, ngtsEnvironmentPresetsObj };
2916
3475
  //# sourceMappingURL=angular-three-soba-staging.mjs.map