angular-three-soba 1.8.0 → 1.9.0

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 +51 -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 +75 -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 +61 -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 +568 -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 +568 -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 +2 -4
  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 +14 -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 +15 -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 } 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,569 @@ 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
+ constructor() {
2644
+ super(...arguments);
2645
+ this.cdr = inject(ChangeDetectorRef);
2646
+ }
2647
+ set distance(distance) {
2648
+ this.set({ distance });
2649
+ }
2650
+ set alphaTest(alphaTest) {
2651
+ this.set({ alphaTest });
2652
+ }
2653
+ set scale(scale) {
2654
+ this.set({ scale });
2655
+ }
2656
+ set map(map) {
2657
+ this.set({ map });
2658
+ }
2659
+ set shader(shader) {
2660
+ this.set({ shader });
2661
+ this.cdr.detectChanges();
2662
+ }
2663
+ set width(width) {
2664
+ this.set({ width });
2665
+ }
2666
+ set height(height) {
2667
+ this.set({ height });
2668
+ }
2669
+ }
2670
+ NgtsSpotLightShadowMeshInput.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowMeshInput, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2671
+ 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 });
2672
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowMeshInput, decorators: [{
2673
+ type: Directive
2674
+ }], propDecorators: { distance: [{
2675
+ type: Input
2676
+ }], alphaTest: [{
2677
+ type: Input
2678
+ }], scale: [{
2679
+ type: Input
2680
+ }], map: [{
2681
+ type: Input
2682
+ }], shader: [{
2683
+ type: Input
2684
+ }], width: [{
2685
+ type: Input
2686
+ }], height: [{
2687
+ type: Input
2688
+ }] } });
2689
+
2690
+ const isSpotLight = (child) => {
2691
+ return child === null || child === void 0 ? void 0 : child.isSpotLight;
2692
+ };
2693
+ function injectShadowMeshCommon(spotLight, mesh, width, height, distance) {
2694
+ const pos = new THREE.Vector3();
2695
+ const dir = new THREE.Vector3();
2696
+ const commonEffect = (instance) => {
2697
+ instance.hold(combineLatest([
2698
+ spotLight.$,
2699
+ instance.select('width').pipe(startWith(width)),
2700
+ instance.select('height').pipe(startWith(height)),
2701
+ ]), ([light, width, height]) => {
2702
+ if (isSpotLight(light)) {
2703
+ console.log('[NGTS] SpotLight instance -->', light);
2704
+ light.shadow.mapSize.set(width, height);
2705
+ light.shadow.needsUpdate = true;
2706
+ }
2707
+ else {
2708
+ throw new Error('<ngts-spot-light-shadow> must be a child of a <ngts-spot-light>');
2709
+ }
2710
+ });
2711
+ };
2712
+ injectBeforeRender(() => {
2713
+ if (!spotLight.nativeElement)
2714
+ return;
2715
+ const A = spotLight.nativeElement.position;
2716
+ const B = spotLight.nativeElement.target.position;
2717
+ dir.copy(B).sub(A);
2718
+ const len = dir.length();
2719
+ dir.normalize().multiplyScalar(len * distance);
2720
+ pos.copy(A).add(dir);
2721
+ mesh.nativeElement.position.copy(pos);
2722
+ mesh.nativeElement.lookAt(spotLight.nativeElement.target.position);
2723
+ });
2724
+ return commonEffect;
2725
+ }
2726
+
2727
+ extend({ Mesh, PlaneGeometry, MeshBasicMaterial });
2728
+ class NgtsSpotLightShadowNoShader extends NgtsSpotLightShadowMeshInput {
2729
+ constructor() {
2730
+ super(...arguments);
2731
+ this.mesh = injectNgtRef();
2732
+ this.spotLightApi = inject(NGTS_SPOT_LIGHT_API);
2733
+ this.DoubleSide = THREE.DoubleSide;
2734
+ this.RepeatWrapping = THREE.RepeatWrapping;
2735
+ this.runInContext = createRunInContext();
2736
+ }
2737
+ initialize() {
2738
+ super.initialize();
2739
+ this.set({ distance: 0.4, alphaTest: 0.5, width: 512, height: 512 });
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
+ *ngIf="!!get('map')"
2754
+ [transparent]="true"
2755
+ [side]="DoubleSide"
2756
+ [alphaTest]="get('alphaTest')"
2757
+ [alphaMap]="get('map')"
2758
+ [opacity]="spotLightApi.debug ? 1 : 0"
2759
+ >
2760
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapS" />
2761
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapT" />
2762
+ <ng-content />
2763
+ </ngt-mesh-basic-material>
2764
+ </ngt-mesh>
2765
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2766
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowNoShader, decorators: [{
2767
+ type: Component,
2768
+ args: [{
2769
+ selector: 'ngts-spot-light-shadow-no-shader',
2770
+ standalone: true,
2771
+ template: `
2772
+ <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
2773
+ <ngt-plane-geometry />
2774
+ <ngt-mesh-basic-material
2775
+ *ngIf="!!get('map')"
2776
+ [transparent]="true"
2777
+ [side]="DoubleSide"
2778
+ [alphaTest]="get('alphaTest')"
2779
+ [alphaMap]="get('map')"
2780
+ [opacity]="spotLightApi.debug ? 1 : 0"
2781
+ >
2782
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapS" />
2783
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapT" />
2784
+ <ng-content />
2785
+ </ngt-mesh-basic-material>
2786
+ </ngt-mesh>
2787
+ `,
2788
+ imports: [NgIf],
2789
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2790
+ }]
2791
+ }] });
2792
+
2793
+ extend({ Mesh, PlaneGeometry, MeshBasicMaterial });
2794
+ class NgtsSpotLightShadowShader extends NgtsSpotLightShadowMeshInput {
2795
+ initialize() {
2796
+ super.initialize();
2797
+ this.set({ distance: 0.4, alphaTest: 0.5, width: 512, height: 512, scale: 1 });
2798
+ }
2799
+ constructor() {
2800
+ super();
2801
+ this.mesh = injectNgtRef();
2802
+ this.spotLightApi = inject(NGTS_SPOT_LIGHT_API);
2803
+ this.DoubleSide = THREE.DoubleSide;
2804
+ this.RepeatWrapping = THREE.RepeatWrapping;
2805
+ this.runInContext = createRunInContext();
2806
+ this.texture$ = this.select('renderTarget', 'texture');
2807
+ this.uniforms = {
2808
+ uShadowMap: { value: this.get('map') },
2809
+ uTime: { value: 0 },
2810
+ };
2811
+ this.connect('renderTarget', combineLatest([this.select('width'), this.select('height')]).pipe(map(([width, height]) => {
2812
+ return new THREE.WebGLRenderTarget(width, height, {
2813
+ format: THREE.RGBAFormat,
2814
+ encoding: THREE.LinearEncoding,
2815
+ stencilBuffer: false,
2816
+ // depthTexture: null!
2817
+ });
2818
+ })));
2819
+ this.connect('fsQuad', this.select('shader').pipe(map((shader) => {
2820
+ return new FullScreenQuad(new THREE.ShaderMaterial({
2821
+ uniforms: this.uniforms,
2822
+ vertexShader: /* glsl */ `
2823
+ varying vec2 vUv;
2824
+
2825
+ void main() {
2826
+ vUv = uv;
2827
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
2828
+ }
2829
+ `,
2830
+ fragmentShader: shader,
2831
+ }));
2832
+ })));
2833
+ this.hold(this.select('map'), (map) => {
2834
+ this.uniforms.uShadowMap.value = map;
2835
+ });
2836
+ this.effect(this.select('fsQuad'), (fsQuad) => {
2837
+ return () => {
2838
+ fsQuad.dispose();
2839
+ fsQuad.material.dispose();
2840
+ };
2841
+ });
2842
+ this.effect(this.select('renderTarget'), (renderTarget) => {
2843
+ return () => {
2844
+ renderTarget.dispose();
2845
+ };
2846
+ });
2847
+ injectBeforeRender(({ delta, gl }) => {
2848
+ this.uniforms.uTime.value += delta;
2849
+ const { fsQuad, renderTarget } = this.get();
2850
+ if (fsQuad && renderTarget) {
2851
+ gl.setRenderTarget(renderTarget);
2852
+ fsQuad.render(gl);
2853
+ gl.setRenderTarget(null);
2854
+ }
2855
+ });
2856
+ }
2857
+ ngOnInit() {
2858
+ const commonEffect = this.runInContext(() => {
2859
+ return injectShadowMeshCommon(this.spotLightApi.spotLight, this.mesh, this.get('width'), this.get('height'), this.get('distance'));
2860
+ });
2861
+ commonEffect(this);
2862
+ }
2863
+ }
2864
+ NgtsSpotLightShadowShader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowShader, deps: [], target: i0.ɵɵFactoryTarget.Component });
2865
+ 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: `
2866
+ <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
2867
+ <ngt-plane-geometry />
2868
+ <ngt-mesh-basic-material
2869
+ [transparent]="true"
2870
+ [side]="DoubleSide"
2871
+ [alphaTest]="get('alphaTest')"
2872
+ [alphaMap]="texture$ | ngtPush"
2873
+ [opacity]="spotLightApi.debug ? 1 : 0"
2874
+ >
2875
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapS" />
2876
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapT" />
2877
+ <ng-content />
2878
+ </ngt-mesh-basic-material>
2879
+ </ngt-mesh>
2880
+ `, isInline: true, dependencies: [{ kind: "pipe", type: NgtPush, name: "ngtPush" }] });
2881
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadowShader, decorators: [{
2882
+ type: Component,
2883
+ args: [{
2884
+ selector: 'ngts-spot-light-shadow-shader',
2885
+ standalone: true,
2886
+ template: `
2887
+ <ngt-mesh [ref]="mesh" [scale]="get('scale')" [castShadow]="true">
2888
+ <ngt-plane-geometry />
2889
+ <ngt-mesh-basic-material
2890
+ [transparent]="true"
2891
+ [side]="DoubleSide"
2892
+ [alphaTest]="get('alphaTest')"
2893
+ [alphaMap]="texture$ | ngtPush"
2894
+ [opacity]="spotLightApi.debug ? 1 : 0"
2895
+ >
2896
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapS" />
2897
+ <ngt-value [rawValue]="RepeatWrapping" attach="alphaMap.wrapT" />
2898
+ <ng-content />
2899
+ </ngt-mesh-basic-material>
2900
+ </ngt-mesh>
2901
+ `,
2902
+ imports: [NgtPush],
2903
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2904
+ }]
2905
+ }], ctorParameters: function () { return []; } });
2906
+
2907
+ class NgtsSpotLightShadow extends NgtsSpotLightShadowMeshInput {
2908
+ }
2909
+ NgtsSpotLightShadow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadow, deps: null, target: i0.ɵɵFactoryTarget.Component });
2910
+ 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: `
2911
+ <ngts-spot-light-shadow-shader
2912
+ *ngIf="!!get('shader')"
2913
+ [distance]="get('distance')"
2914
+ [shader]="get('shader')"
2915
+ [alphaTest]="get('alphaTest')"
2916
+ [scale]="get('scale')"
2917
+ [map]="get('map')"
2918
+ [width]="get('width')"
2919
+ [height]="get('height')"
2920
+ />
2921
+ <ngts-spot-light-shadow-no-shader
2922
+ *ngIf="!get('shader')"
2923
+ [distance]="get('distance')"
2924
+ [alphaTest]="get('alphaTest')"
2925
+ [scale]="get('scale')"
2926
+ [map]="get('map')"
2927
+ [width]="get('width')"
2928
+ [height]="get('height')"
2929
+ />
2930
+ `, 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"] }] });
2931
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgtsSpotLightShadow, decorators: [{
2932
+ type: Component,
2933
+ args: [{
2934
+ selector: 'ngts-spot-light-shadow',
2935
+ standalone: true,
2936
+ template: `
2937
+ <ngts-spot-light-shadow-shader
2938
+ *ngIf="!!get('shader')"
2939
+ [distance]="get('distance')"
2940
+ [shader]="get('shader')"
2941
+ [alphaTest]="get('alphaTest')"
2942
+ [scale]="get('scale')"
2943
+ [map]="get('map')"
2944
+ [width]="get('width')"
2945
+ [height]="get('height')"
2946
+ />
2947
+ <ngts-spot-light-shadow-no-shader
2948
+ *ngIf="!get('shader')"
2949
+ [distance]="get('distance')"
2950
+ [alphaTest]="get('alphaTest')"
2951
+ [scale]="get('scale')"
2952
+ [map]="get('map')"
2953
+ [width]="get('width')"
2954
+ [height]="get('height')"
2955
+ />
2956
+ `,
2957
+ imports: [NgtsSpotLightShadowShader, NgtsSpotLightShadowNoShader, NgIf, NgtPush],
2958
+ }]
2959
+ }] });
2960
+
2398
2961
  const presets = {
2399
2962
  rembrandt: {
2400
2963
  main: [1, 2, 1],
@@ -2912,5 +3475,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2912
3475
  * Generated bundle index. Do not edit.
2913
3476
  */
2914
3477
 
2915
- export { NGTS_BOUNDS_API, NgtsAccumulativeShadows, NgtsBounds, NgtsCameraShake, NgtsCenter, NgtsCloud, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentContent, NgtsFloat, NgtsRandomizedLights, NgtsSky, NgtsSparkles, NgtsStage, NgtsStageRefit, NgtsStars, calcPosFromAngles, ngtsEnvironmentPresetsObj };
3478
+ 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
3479
  //# sourceMappingURL=angular-three-soba-staging.mjs.map