angular-three-soba 1.9.3 → 1.11.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 (123) hide show
  1. package/abstractions/index.d.ts +1 -0
  2. package/abstractions/lib/edges/edges.d.ts +18 -0
  3. package/cameras/index.d.ts +1 -0
  4. package/cameras/lib/camera/camera-content.d.ts +1 -1
  5. package/cameras/lib/cube-camera/cube-camera.d.ts +27 -0
  6. package/esm2020/abstractions/index.mjs +2 -1
  7. package/esm2020/abstractions/lib/billboard/billboard.mjs +3 -3
  8. package/esm2020/abstractions/lib/catmull-rom-line/catmull-rom-line.mjs +3 -3
  9. package/esm2020/abstractions/lib/cubic-bezier-line/cubic-bezier-line.mjs +3 -3
  10. package/esm2020/abstractions/lib/edges/edges.mjs +95 -0
  11. package/esm2020/abstractions/lib/gizmo-helper/gizmo-helper.mjs +6 -6
  12. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.mjs +3 -3
  13. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.mjs +6 -6
  14. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.mjs +3 -3
  15. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.mjs +3 -3
  16. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.mjs +6 -6
  17. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.mjs +3 -3
  18. package/esm2020/abstractions/lib/line/line-input.mjs +3 -3
  19. package/esm2020/abstractions/lib/line/line.mjs +3 -3
  20. package/esm2020/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.mjs +3 -3
  21. package/esm2020/abstractions/lib/text/text.mjs +3 -3
  22. package/esm2020/abstractions/lib/text-3d/text-3d.mjs +3 -3
  23. package/esm2020/cameras/index.mjs +2 -1
  24. package/esm2020/cameras/lib/camera/camera-content.mjs +4 -4
  25. package/esm2020/cameras/lib/camera/camera.mjs +3 -3
  26. package/esm2020/cameras/lib/cube-camera/cube-camera.mjs +130 -0
  27. package/esm2020/cameras/lib/orthographic-camera/orthographic-camera.mjs +3 -3
  28. package/esm2020/cameras/lib/perspective-camera/perspective-camera.mjs +3 -3
  29. package/esm2020/controls/lib/orbit-controls/orbit-controls.mjs +3 -3
  30. package/esm2020/loaders/lib/loader/loader.mjs +3 -3
  31. package/esm2020/materials/index.mjs +3 -1
  32. package/esm2020/materials/lib/mesh-distort-material/mesh-distort-material.mjs +3 -3
  33. package/esm2020/materials/lib/mesh-reflector-material/mesh-reflector-material.mjs +3 -3
  34. package/esm2020/materials/lib/mesh-refraction-material/mesh-refraction-material.mjs +157 -0
  35. package/esm2020/materials/lib/mesh-transmission-material/mesh-transmission-material.mjs +240 -0
  36. package/esm2020/materials/lib/mesh-wobble-material/mesh-wobble-material.mjs +3 -3
  37. package/esm2020/misc/lib/bake-shadows/bake-shadows.mjs +3 -3
  38. package/esm2020/misc/lib/fbo/fbo.mjs +5 -4
  39. package/esm2020/performance/lib/adaptive/adaptive-dpr.mjs +3 -3
  40. package/esm2020/performance/lib/adaptive/adaptive-events.mjs +3 -3
  41. package/esm2020/performance/lib/detailed/detailed.mjs +3 -3
  42. package/esm2020/performance/lib/stats/stats.mjs +3 -3
  43. package/esm2020/shaders/index.mjs +6 -1
  44. package/esm2020/shaders/lib/caustics-material/caustics-material.mjs +128 -0
  45. package/esm2020/shaders/lib/caustics-projection-material/caustics-projection-material.mjs +33 -0
  46. package/esm2020/shaders/lib/discard-material/discard-material.mjs +3 -0
  47. package/esm2020/shaders/lib/mesh-refraction-material/mesh-refraction-material.mjs +169 -0
  48. package/esm2020/shaders/lib/mesh-transmission-material/mesh-transmission-material.mjs +268 -0
  49. package/esm2020/staging/index.mjs +2 -1
  50. package/esm2020/staging/lib/accumulative-shadows/accumulative-shadows.mjs +6 -6
  51. package/esm2020/staging/lib/accumulative-shadows/progressive-light-map.mjs +2 -3
  52. package/esm2020/staging/lib/accumulative-shadows/randomized-lights.mjs +6 -6
  53. package/esm2020/staging/lib/bounds/bounds.mjs +3 -3
  54. package/esm2020/staging/lib/camera-shake/camera-shake.mjs +3 -3
  55. package/esm2020/staging/lib/caustics/caustics.mjs +364 -0
  56. package/esm2020/staging/lib/center/center.mjs +3 -3
  57. package/esm2020/staging/lib/cloud/cloud.mjs +3 -3
  58. package/esm2020/staging/lib/contact-shadows/contact-shadows.mjs +3 -3
  59. package/esm2020/staging/lib/environment/environment-cube.mjs +3 -3
  60. package/esm2020/staging/lib/environment/environment-ground.mjs +3 -3
  61. package/esm2020/staging/lib/environment/environment-inputs.mjs +3 -3
  62. package/esm2020/staging/lib/environment/environment-map.mjs +3 -3
  63. package/esm2020/staging/lib/environment/environment-portal.mjs +3 -3
  64. package/esm2020/staging/lib/environment/environment.mjs +6 -6
  65. package/esm2020/staging/lib/float/float.mjs +3 -3
  66. package/esm2020/staging/lib/sky/sky.mjs +3 -3
  67. package/esm2020/staging/lib/sparkles/sparkles.mjs +3 -3
  68. package/esm2020/staging/lib/spot-light/shadow-mesh-input.mjs +3 -3
  69. package/esm2020/staging/lib/spot-light/spot-light-input.mjs +3 -3
  70. package/esm2020/staging/lib/spot-light/spot-light-shadow-no-shader.mjs +3 -3
  71. package/esm2020/staging/lib/spot-light/spot-light-shadow-shader.mjs +3 -3
  72. package/esm2020/staging/lib/spot-light/spot-light-shadow.mjs +3 -3
  73. package/esm2020/staging/lib/spot-light/spot-light.mjs +3 -3
  74. package/esm2020/staging/lib/spot-light/volumetric-mesh.mjs +3 -3
  75. package/esm2020/staging/lib/stage/stage.mjs +6 -6
  76. package/esm2020/staging/lib/stars/stars.mjs +3 -3
  77. package/fesm2015/angular-three-soba-abstractions.mjs +145 -56
  78. package/fesm2015/angular-three-soba-abstractions.mjs.map +1 -1
  79. package/fesm2015/angular-three-soba-cameras.mjs +139 -16
  80. package/fesm2015/angular-three-soba-cameras.mjs.map +1 -1
  81. package/fesm2015/angular-three-soba-controls.mjs +3 -3
  82. package/fesm2015/angular-three-soba-loaders.mjs +3 -3
  83. package/fesm2015/angular-three-soba-materials.mjs +398 -11
  84. package/fesm2015/angular-three-soba-materials.mjs.map +1 -1
  85. package/fesm2015/angular-three-soba-misc.mjs +7 -6
  86. package/fesm2015/angular-three-soba-misc.mjs.map +1 -1
  87. package/fesm2015/angular-three-soba-performance.mjs +12 -12
  88. package/fesm2015/angular-three-soba-shaders.mjs +619 -31
  89. package/fesm2015/angular-three-soba-shaders.mjs.map +1 -1
  90. package/fesm2015/angular-three-soba-staging.mjs +450 -96
  91. package/fesm2015/angular-three-soba-staging.mjs.map +1 -1
  92. package/fesm2020/angular-three-soba-abstractions.mjs +145 -56
  93. package/fesm2020/angular-three-soba-abstractions.mjs.map +1 -1
  94. package/fesm2020/angular-three-soba-cameras.mjs +139 -16
  95. package/fesm2020/angular-three-soba-cameras.mjs.map +1 -1
  96. package/fesm2020/angular-three-soba-controls.mjs +3 -3
  97. package/fesm2020/angular-three-soba-loaders.mjs +3 -3
  98. package/fesm2020/angular-three-soba-materials.mjs +396 -11
  99. package/fesm2020/angular-three-soba-materials.mjs.map +1 -1
  100. package/fesm2020/angular-three-soba-misc.mjs +7 -6
  101. package/fesm2020/angular-three-soba-misc.mjs.map +1 -1
  102. package/fesm2020/angular-three-soba-performance.mjs +12 -12
  103. package/fesm2020/angular-three-soba-shaders.mjs +625 -34
  104. package/fesm2020/angular-three-soba-shaders.mjs.map +1 -1
  105. package/fesm2020/angular-three-soba-staging.mjs +449 -96
  106. package/fesm2020/angular-three-soba-staging.mjs.map +1 -1
  107. package/materials/index.d.ts +2 -0
  108. package/materials/lib/mesh-refraction-material/mesh-refraction-material.d.ts +28 -0
  109. package/materials/lib/mesh-transmission-material/mesh-transmission-material.d.ts +47 -0
  110. package/misc/lib/fbo/fbo.d.ts +8 -6
  111. package/package.json +4 -3
  112. package/plugin/package.json +1 -1
  113. package/shaders/index.d.ts +5 -0
  114. package/shaders/lib/caustics-material/caustics-material.d.ts +4 -0
  115. package/shaders/lib/caustics-projection-material/caustics-projection-material.d.ts +4 -0
  116. package/shaders/lib/discard-material/discard-material.d.ts +3 -0
  117. package/shaders/lib/mesh-refraction-material/mesh-refraction-material.d.ts +4 -0
  118. package/shaders/lib/mesh-transmission-material/mesh-transmission-material.d.ts +25 -0
  119. package/staging/index.d.ts +1 -0
  120. package/staging/lib/caustics/caustics.d.ts +48 -0
  121. package/staging/lib/environment/environment-cube.d.ts +1 -1
  122. package/staging/lib/environment/environment-ground.d.ts +1 -1
  123. package/staging/lib/environment/utils.d.ts +1 -1
@@ -1,10 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { inject, Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core';
3
3
  import { NgtRxStore, injectNgtRef, injectBeforeRender, NgtArgs, extend, NgtStore, startWithUndefined, getLocalState, NgtPush } from 'angular-three';
4
- import { NGTS_DISTORT_MATERIAL_SHADER, MeshReflectorMaterial, BlurPass, MeshWobbleMaterial } from 'angular-three-soba/shaders';
4
+ import { NGTS_DISTORT_MATERIAL_SHADER, MeshReflectorMaterial, BlurPass, MeshRefractionMaterial, MeshTransmissionMaterial, DiscardMaterial, MeshWobbleMaterial } from 'angular-three-soba/shaders';
5
5
  import { NgIf } from '@angular/common';
6
6
  import { debounceTime, map, combineLatest } from 'rxjs';
7
7
  import * as THREE from 'three';
8
+ import { MeshBVH, SAH } from 'three-mesh-bvh';
9
+ import { injectNgtsFBO } from 'angular-three-soba/misc';
8
10
 
9
11
  class NgtsMeshDistortMaterial extends NgtRxStore {
10
12
  set time(time) {
@@ -33,8 +35,8 @@ class NgtsMeshDistortMaterial extends NgtRxStore {
33
35
  });
34
36
  }
35
37
  }
36
- NgtsMeshDistortMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: NgtsMeshDistortMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
37
- NgtsMeshDistortMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: NgtsMeshDistortMaterial, isStandalone: true, selector: "ngts-mesh-distort-material", inputs: { materialRef: "materialRef", time: "time", distort: "distort", radius: "radius", speed: "speed" }, usesInheritance: true, ngImport: i0, template: `
38
+ NgtsMeshDistortMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshDistortMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
39
+ NgtsMeshDistortMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtsMeshDistortMaterial, isStandalone: true, selector: "ngts-mesh-distort-material", inputs: { materialRef: "materialRef", time: "time", distort: "distort", radius: "radius", speed: "speed" }, usesInheritance: true, ngImport: i0, template: `
38
40
  <ngt-primitive
39
41
  *args="[material]"
40
42
  [ref]="materialRef"
@@ -45,7 +47,7 @@ NgtsMeshDistortMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0"
45
47
  attach="material"
46
48
  />
47
49
  `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
48
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: NgtsMeshDistortMaterial, decorators: [{
50
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshDistortMaterial, decorators: [{
49
51
  type: Component,
50
52
  args: [{
51
53
  selector: 'ngts-mesh-distort-material',
@@ -305,8 +307,8 @@ class NgtsMeshReflectorMaterial extends NgtRxStore {
305
307
  }
306
308
  }
307
309
  }
308
- NgtsMeshReflectorMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: NgtsMeshReflectorMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
309
- NgtsMeshReflectorMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: NgtsMeshReflectorMaterial, isStandalone: true, selector: "ngts-mesh-reflector-material", inputs: { materialRef: "materialRef", resolution: "resolution", mixBlur: "mixBlur", mixStrength: "mixStrength", blur: "blur", mirror: "mirror", minDepthThreshold: "minDepthThreshold", maxDepthThreshold: "maxDepthThreshold", depthScale: "depthScale", depthToBlurRatioBias: "depthToBlurRatioBias", distortionMap: "distortionMap", distortion: "distortion", mixContrast: "mixContrast", reflectorOffset: "reflectorOffset" }, usesInheritance: true, ngImport: i0, template: `
310
+ NgtsMeshReflectorMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshReflectorMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
311
+ NgtsMeshReflectorMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtsMeshReflectorMaterial, isStandalone: true, selector: "ngts-mesh-reflector-material", inputs: { materialRef: "materialRef", resolution: "resolution", mixBlur: "mixBlur", mixStrength: "mixStrength", blur: "blur", mirror: "mirror", minDepthThreshold: "minDepthThreshold", maxDepthThreshold: "maxDepthThreshold", depthScale: "depthScale", depthToBlurRatioBias: "depthToBlurRatioBias", distortionMap: "distortionMap", distortion: "distortion", mixContrast: "mixContrast", reflectorOffset: "reflectorOffset" }, usesInheritance: true, ngImport: i0, template: `
310
312
  <ngt-mesh-reflector-material
311
313
  ngtCompound
312
314
  attach="material"
@@ -332,7 +334,7 @@ NgtsMeshReflectorMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.
332
334
  <ng-content />
333
335
  </ngt-mesh-reflector-material>
334
336
  `, isInline: true, dependencies: [{ kind: "pipe", type: NgtPush, name: "ngtPush" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
335
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: NgtsMeshReflectorMaterial, decorators: [{
337
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshReflectorMaterial, decorators: [{
336
338
  type: Component,
337
339
  args: [{
338
340
  selector: 'ngts-mesh-reflector-material',
@@ -396,6 +398,391 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
396
398
  type: Input
397
399
  }] } });
398
400
 
401
+ extend({ MeshRefractionMaterial });
402
+ const isCubeTexture = (def) => def && def.isCubeTexture;
403
+ class NgtsMeshRefractionMaterial extends NgtRxStore {
404
+ /** Environment map */
405
+ set envMap(envMap) {
406
+ this.set({ envMap });
407
+ }
408
+ /** Number of ray-cast bounces, it can be expensive to have too many, 2 */
409
+ set bounces(bounces) {
410
+ this.set({ bounces });
411
+ }
412
+ /** Refraction index, 2.4 */
413
+ set ior(ior) {
414
+ this.set({ ior });
415
+ }
416
+ /** Fresnel (strip light), 0 */
417
+ set fresnel(fresnel) {
418
+ this.set({ fresnel });
419
+ }
420
+ /** RGB shift intensity, can be expensive, 0 */
421
+ set aberrationStrength(aberrationStrength) {
422
+ this.set({ aberrationStrength });
423
+ }
424
+ /** Color, white */
425
+ set color(color) {
426
+ this.set({ color });
427
+ }
428
+ /** If this is on it uses fewer ray casts for the RGB shift sacrificing physical accuracy, true */
429
+ set fastChroma(fastChroma) {
430
+ this.set({ fastChroma });
431
+ }
432
+ initialize() {
433
+ super.initialize();
434
+ this.set({
435
+ aberrationStrength: 0,
436
+ fastChroma: true,
437
+ });
438
+ }
439
+ constructor() {
440
+ super();
441
+ this.materialRef = injectNgtRef();
442
+ this.defines$ = this.select('defines');
443
+ this.store = inject(NgtStore);
444
+ this.connect('defines', combineLatest([this.select('aberrationStrength'), this.select('fastChroma'), this.select('envMap')]).pipe(map(([aberrationStrength, fastChroma, envMap]) => {
445
+ var _a, _b;
446
+ const temp = {};
447
+ // Sampler2D and SamplerCube need different defines
448
+ const isCubeMap = isCubeTexture(envMap);
449
+ const w = (_b = (isCubeMap ? (_a = envMap.image[0]) === null || _a === void 0 ? void 0 : _a.width : envMap.image.width)) !== null && _b !== void 0 ? _b : 1024;
450
+ const cubeSize = w / 4;
451
+ const _lodMax = Math.floor(Math.log2(cubeSize));
452
+ const _cubeSize = Math.pow(2, _lodMax);
453
+ const width = 3 * Math.max(_cubeSize, 16 * 7);
454
+ const height = 4 * _cubeSize;
455
+ if (isCubeMap)
456
+ temp['ENVMAP_TYPE_CUBEM'] = '';
457
+ temp['CUBEUV_TEXEL_WIDTH'] = `${1.0 / width}`;
458
+ temp['CUBEUV_TEXEL_HEIGHT'] = `${1.0 / height}`;
459
+ temp['CUBEUV_MAX_MIP'] = `${_lodMax}.0`;
460
+ // Add defines from chromatic aberration
461
+ if (aberrationStrength > 0)
462
+ temp['CHROMATIC_ABERRATIONS'] = '';
463
+ if (fastChroma)
464
+ temp['FAST_CHROMA'] = '';
465
+ return temp;
466
+ })));
467
+ this.connect('resolution', this.store.select('size').pipe(map((size) => [size.width, size.height])));
468
+ injectBeforeRender(({ camera }) => {
469
+ if (this.materialRef.nativeElement) {
470
+ this.materialRef.nativeElement.viewMatrixInverse = camera.matrixWorld;
471
+ this.materialRef.nativeElement.projectionMatrixInverse = camera.projectionMatrixInverse;
472
+ }
473
+ });
474
+ }
475
+ ngOnInit() {
476
+ this.setupGeometry();
477
+ }
478
+ setupGeometry() {
479
+ this.hold(this.materialRef.$, (material) => {
480
+ var _a;
481
+ const geometry = (_a = getLocalState(material).parent) === null || _a === void 0 ? void 0 : _a.geometry;
482
+ if (geometry) {
483
+ material.bvh.updateFrom(new MeshBVH(geometry.toNonIndexed(), { lazyGeneration: false, strategy: SAH }));
484
+ }
485
+ });
486
+ }
487
+ }
488
+ NgtsMeshRefractionMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshRefractionMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
489
+ NgtsMeshRefractionMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtsMeshRefractionMaterial, isStandalone: true, selector: "ngts-mesh-refraction-material", inputs: { materialRef: "materialRef", envMap: "envMap", bounces: "bounces", ior: "ior", fresnel: "fresnel", aberrationStrength: "aberrationStrength", color: "color", fastChroma: "fastChroma" }, usesInheritance: true, ngImport: i0, template: `
490
+ <ngt-mesh-refraction-material
491
+ *ngIf="defines$ | ngtPush as defines"
492
+ [ref]="materialRef"
493
+ [defines]="defines"
494
+ [resolution]="get('resolution')"
495
+ [aberrationStrength]="get('aberrationStrength')"
496
+ [envMap]="get('envMap')"
497
+ [bounces]="get('bounces')"
498
+ [ior]="get('ior')"
499
+ [fresnel]="get('fresnel')"
500
+ [color]="get('color')"
501
+ [fastChroma]="get('fastChroma')"
502
+ ngtCompound
503
+ attach="material"
504
+ >
505
+ <ng-content />
506
+ </ngt-mesh-refraction-material>
507
+ `, isInline: true, dependencies: [{ kind: "pipe", type: NgtPush, name: "ngtPush" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
508
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshRefractionMaterial, decorators: [{
509
+ type: Component,
510
+ args: [{
511
+ selector: 'ngts-mesh-refraction-material',
512
+ standalone: true,
513
+ template: `
514
+ <ngt-mesh-refraction-material
515
+ *ngIf="defines$ | ngtPush as defines"
516
+ [ref]="materialRef"
517
+ [defines]="defines"
518
+ [resolution]="get('resolution')"
519
+ [aberrationStrength]="get('aberrationStrength')"
520
+ [envMap]="get('envMap')"
521
+ [bounces]="get('bounces')"
522
+ [ior]="get('ior')"
523
+ [fresnel]="get('fresnel')"
524
+ [color]="get('color')"
525
+ [fastChroma]="get('fastChroma')"
526
+ ngtCompound
527
+ attach="material"
528
+ >
529
+ <ng-content />
530
+ </ngt-mesh-refraction-material>
531
+ `,
532
+ imports: [NgtPush, NgIf],
533
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
534
+ }]
535
+ }], ctorParameters: function () { return []; }, propDecorators: { materialRef: [{
536
+ type: Input
537
+ }], envMap: [{
538
+ type: Input
539
+ }], bounces: [{
540
+ type: Input
541
+ }], ior: [{
542
+ type: Input
543
+ }], fresnel: [{
544
+ type: Input
545
+ }], aberrationStrength: [{
546
+ type: Input
547
+ }], color: [{
548
+ type: Input
549
+ }], fastChroma: [{
550
+ type: Input
551
+ }] } });
552
+
553
+ extend({ MeshTransmissionMaterial });
554
+ class NgtsMeshTranmissionMaterial extends NgtRxStore {
555
+ /** transmissionSampler, you can use the threejs transmission sampler texture that is
556
+ * generated once for all transmissive materials. The upside is that it can be faster if you
557
+ * use multiple MeshPhysical and Transmission materials, the downside is that transmissive materials
558
+ * using this can't see other transparent or transmissive objects, default: false */
559
+ set transmissionSampler(transmissionSampler) {
560
+ this.set({ transmissionSampler });
561
+ }
562
+ /** Render the backside of the material (more cost, better results), default: false */
563
+ set backside(backside) {
564
+ this.set({ backside });
565
+ }
566
+ /** Backside thickness (when backside is true), default: 0 */
567
+ set backsideThickness(backsideThickness) {
568
+ this.set({ backsideThickness });
569
+ }
570
+ /** Resolution of the local buffer, default: undefined (fullscreen) */
571
+ set resolution(resolution) {
572
+ this.set({ resolution });
573
+ }
574
+ /** Resolution of the local buffer for backfaces, default: undefined (fullscreen) */
575
+ set backsideResolution(backsideResolution) {
576
+ this.set({ backsideResolution });
577
+ }
578
+ /** Refraction samples, default: 10 */
579
+ set samples(samples) {
580
+ this.set({ samples });
581
+ }
582
+ /** Buffer scene background (can be a texture, a cubetexture or a color), default: null */
583
+ set background(background) {
584
+ this.set({ background });
585
+ }
586
+ /* Transmission, default: 1 */
587
+ set transmission(transmission) {
588
+ this.set({ transmission });
589
+ }
590
+ /* Thickness (refraction), default: 0 */
591
+ set thickness(thickness) {
592
+ this.set({ thickness });
593
+ }
594
+ /* Roughness (blur), default: 0 */
595
+ set roughness(roughness) {
596
+ this.set({ roughness });
597
+ }
598
+ /* Chromatic aberration, default: 0.03 */
599
+ set chromaticAberration(chromaticAberration) {
600
+ this.set({ chromaticAberration });
601
+ }
602
+ /* Anisotropy, default: 0.1 */
603
+ set anisotropy(anisotropy) {
604
+ this.set({ anisotropy });
605
+ }
606
+ /* Distortion, default: 0 */
607
+ set distortion(distortion) {
608
+ this.set({ distortion });
609
+ }
610
+ /* Distortion scale, default: 0.5 */
611
+ set distortionScale(distortionScale) {
612
+ this.set({ distortionScale });
613
+ }
614
+ /* Temporal distortion (speed of movement), default: 0.0 */
615
+ set temporalDistortion(temporalDistortion) {
616
+ this.set({ temporalDistortion });
617
+ }
618
+ /** The scene rendered into a texture (use it to share a texture between materials), default: null */
619
+ set buffer(buffer) {
620
+ this.set({ buffer });
621
+ }
622
+ /** Internals */
623
+ set time(time) {
624
+ this.set({ time });
625
+ }
626
+ initialize() {
627
+ super.initialize();
628
+ this.set({
629
+ transmissionSampler: false,
630
+ backside: false,
631
+ side: THREE.FrontSide,
632
+ transmission: 1,
633
+ thickness: 0,
634
+ backsideThickness: 0,
635
+ samples: 10,
636
+ roughness: 0,
637
+ anisotropy: 0.1,
638
+ chromaticAberration: 0.03,
639
+ distortion: 0,
640
+ distortionScale: 0.5,
641
+ temporalDistortion: 0.0,
642
+ buffer: null,
643
+ });
644
+ }
645
+ constructor() {
646
+ super();
647
+ this.materialRef = injectNgtRef();
648
+ this.discardMaterial = new DiscardMaterial();
649
+ this.fboBackRef = injectNgtsFBO(() => combineLatest([this.select('backsideResolution'), this.select('resolution')]).pipe(map(([backsideResolution, resolution]) => backsideResolution || resolution)));
650
+ this.fboMainRef = injectNgtsFBO(() => this.select('resolution'));
651
+ let oldBg;
652
+ let oldTone;
653
+ let parent;
654
+ injectBeforeRender((state) => {
655
+ const { transmissionSampler, background, backside, backsideThickness, thickness, side } = this.get();
656
+ this.materialRef.nativeElement.time = state.clock.getElapsedTime();
657
+ // Render only if the buffer matches the built-in and no transmission sampler is set
658
+ if (this.materialRef.nativeElement.buffer === this.fboMainRef.nativeElement.texture &&
659
+ !transmissionSampler) {
660
+ parent = getLocalState(this.materialRef.nativeElement).parent;
661
+ if (parent) {
662
+ // Save defaults
663
+ oldTone = state.gl.toneMapping;
664
+ oldBg = state.scene.background;
665
+ // Switch off tonemapping lest it double tone maps
666
+ // Save the current background and set the HDR as the new BG
667
+ // Use discardmaterial, the parent will be invisible, but it's shadows will still be cast
668
+ state.gl.toneMapping = THREE.NoToneMapping;
669
+ if (background)
670
+ state.scene.background = background;
671
+ parent['material'] = this.discardMaterial;
672
+ if (backside) {
673
+ // Render into the backside buffer
674
+ state.gl.setRenderTarget(this.fboBackRef.nativeElement);
675
+ state.gl.render(state.scene, state.camera);
676
+ // And now prepare the material for the main render using the backside buffer
677
+ parent['material'] = this.materialRef.nativeElement;
678
+ parent['material'].buffer = this.fboBackRef.nativeElement.texture;
679
+ parent['material'].thickness = backsideThickness;
680
+ parent['material'].side = THREE.BackSide;
681
+ }
682
+ // Render into the main buffer
683
+ state.gl.setRenderTarget(this.fboMainRef.nativeElement);
684
+ state.gl.render(state.scene, state.camera);
685
+ parent['material'].thickness = thickness;
686
+ parent['material'].side = side;
687
+ parent['material'].buffer = this.fboMainRef.nativeElement.texture;
688
+ // Set old state back
689
+ state.scene.background = oldBg;
690
+ state.gl.setRenderTarget(null);
691
+ parent['material'] = this.materialRef.nativeElement;
692
+ state.gl.toneMapping = oldTone;
693
+ }
694
+ }
695
+ });
696
+ }
697
+ ngOnInit() {
698
+ console.log(this.materialRef);
699
+ }
700
+ }
701
+ NgtsMeshTranmissionMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshTranmissionMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
702
+ NgtsMeshTranmissionMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtsMeshTranmissionMaterial, isStandalone: true, selector: "ngts-mesh-transmission-material", inputs: { materialRef: "materialRef", transmissionSampler: "transmissionSampler", backside: "backside", backsideThickness: "backsideThickness", resolution: "resolution", backsideResolution: "backsideResolution", samples: "samples", background: "background", transmission: "transmission", thickness: "thickness", roughness: "roughness", chromaticAberration: "chromaticAberration", anisotropy: "anisotropy", distortion: "distortion", distortionScale: "distortionScale", temporalDistortion: "temporalDistortion", buffer: "buffer", time: "time" }, usesInheritance: true, ngImport: i0, template: `
703
+ <ngt-mesh-transmission-material
704
+ *args="[get('samples'), get('transmissionSampler')]"
705
+ ngtCompound
706
+ [ref]="materialRef"
707
+ [buffer]="get('buffer') || fboMainRef.nativeElement?.texture"
708
+ [_transmission]="get('transmission')"
709
+ [transmission]="get('transmissionSampler') ? get('transmission') : 0"
710
+ [thickness]="get('thickness')"
711
+ [side]="get('side')"
712
+ [anisotropy]="get('anisotropy')"
713
+ [roughness]="get('roughness')"
714
+ [chromaticAberration]="get('chromaticAberration')"
715
+ [distortion]="get('distortion')"
716
+ [distortionScale]="get('distortionScale')"
717
+ [temporalDistortion]="get('temporalDistortion')"
718
+ [time]="get('time')"
719
+ />
720
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
721
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshTranmissionMaterial, decorators: [{
722
+ type: Component,
723
+ args: [{
724
+ selector: 'ngts-mesh-transmission-material',
725
+ standalone: true,
726
+ template: `
727
+ <ngt-mesh-transmission-material
728
+ *args="[get('samples'), get('transmissionSampler')]"
729
+ ngtCompound
730
+ [ref]="materialRef"
731
+ [buffer]="get('buffer') || fboMainRef.nativeElement?.texture"
732
+ [_transmission]="get('transmission')"
733
+ [transmission]="get('transmissionSampler') ? get('transmission') : 0"
734
+ [thickness]="get('thickness')"
735
+ [side]="get('side')"
736
+ [anisotropy]="get('anisotropy')"
737
+ [roughness]="get('roughness')"
738
+ [chromaticAberration]="get('chromaticAberration')"
739
+ [distortion]="get('distortion')"
740
+ [distortionScale]="get('distortionScale')"
741
+ [temporalDistortion]="get('temporalDistortion')"
742
+ [time]="get('time')"
743
+ />
744
+ `,
745
+ imports: [NgtArgs],
746
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
747
+ }]
748
+ }], ctorParameters: function () { return []; }, propDecorators: { materialRef: [{
749
+ type: Input
750
+ }], transmissionSampler: [{
751
+ type: Input
752
+ }], backside: [{
753
+ type: Input
754
+ }], backsideThickness: [{
755
+ type: Input
756
+ }], resolution: [{
757
+ type: Input
758
+ }], backsideResolution: [{
759
+ type: Input
760
+ }], samples: [{
761
+ type: Input
762
+ }], background: [{
763
+ type: Input
764
+ }], transmission: [{
765
+ type: Input
766
+ }], thickness: [{
767
+ type: Input
768
+ }], roughness: [{
769
+ type: Input
770
+ }], chromaticAberration: [{
771
+ type: Input
772
+ }], anisotropy: [{
773
+ type: Input
774
+ }], distortion: [{
775
+ type: Input
776
+ }], distortionScale: [{
777
+ type: Input
778
+ }], temporalDistortion: [{
779
+ type: Input
780
+ }], buffer: [{
781
+ type: Input
782
+ }], time: [{
783
+ type: Input
784
+ }] } });
785
+
399
786
  extend({ MeshWobbleMaterial });
400
787
  class NgtsMeshWobbleMaterial extends NgtRxStore {
401
788
  set time(time) {
@@ -420,8 +807,8 @@ class NgtsMeshWobbleMaterial extends NgtRxStore {
420
807
  });
421
808
  }
422
809
  }
423
- NgtsMeshWobbleMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: NgtsMeshWobbleMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
424
- NgtsMeshWobbleMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: NgtsMeshWobbleMaterial, isStandalone: true, selector: "ngts-mesh-wobble-material", inputs: { materialRef: "materialRef", time: "time", factor: "factor", speed: "speed" }, usesInheritance: true, ngImport: i0, template: `
810
+ NgtsMeshWobbleMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshWobbleMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
811
+ NgtsMeshWobbleMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtsMeshWobbleMaterial, isStandalone: true, selector: "ngts-mesh-wobble-material", inputs: { materialRef: "materialRef", time: "time", factor: "factor", speed: "speed" }, usesInheritance: true, ngImport: i0, template: `
425
812
  <ngt-primitive
426
813
  *args="[material]"
427
814
  [ref]="materialRef"
@@ -431,7 +818,7 @@ NgtsMeshWobbleMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0",
431
818
  ngtCompound
432
819
  />
433
820
  `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
434
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: NgtsMeshWobbleMaterial, decorators: [{
821
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshWobbleMaterial, decorators: [{
435
822
  type: Component,
436
823
  args: [{
437
824
  selector: 'ngts-mesh-wobble-material',
@@ -463,5 +850,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
463
850
  * Generated bundle index. Do not edit.
464
851
  */
465
852
 
466
- export { NgtsMeshDistortMaterial, NgtsMeshReflectorMaterial, NgtsMeshWobbleMaterial };
853
+ export { NgtsMeshDistortMaterial, NgtsMeshReflectorMaterial, NgtsMeshRefractionMaterial, NgtsMeshTranmissionMaterial, NgtsMeshWobbleMaterial };
467
854
  //# sourceMappingURL=angular-three-soba-materials.mjs.map