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.
- package/abstractions/index.d.ts +1 -0
- package/abstractions/lib/edges/edges.d.ts +18 -0
- package/cameras/index.d.ts +1 -0
- package/cameras/lib/camera/camera-content.d.ts +1 -1
- package/cameras/lib/cube-camera/cube-camera.d.ts +27 -0
- package/esm2020/abstractions/index.mjs +2 -1
- package/esm2020/abstractions/lib/billboard/billboard.mjs +3 -3
- package/esm2020/abstractions/lib/catmull-rom-line/catmull-rom-line.mjs +3 -3
- package/esm2020/abstractions/lib/cubic-bezier-line/cubic-bezier-line.mjs +3 -3
- package/esm2020/abstractions/lib/edges/edges.mjs +95 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-helper.mjs +6 -6
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.mjs +3 -3
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.mjs +6 -6
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.mjs +3 -3
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.mjs +3 -3
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.mjs +6 -6
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.mjs +3 -3
- package/esm2020/abstractions/lib/line/line-input.mjs +3 -3
- package/esm2020/abstractions/lib/line/line.mjs +3 -3
- package/esm2020/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.mjs +3 -3
- package/esm2020/abstractions/lib/text/text.mjs +3 -3
- package/esm2020/abstractions/lib/text-3d/text-3d.mjs +3 -3
- package/esm2020/cameras/index.mjs +2 -1
- package/esm2020/cameras/lib/camera/camera-content.mjs +4 -4
- package/esm2020/cameras/lib/camera/camera.mjs +3 -3
- package/esm2020/cameras/lib/cube-camera/cube-camera.mjs +130 -0
- package/esm2020/cameras/lib/orthographic-camera/orthographic-camera.mjs +3 -3
- package/esm2020/cameras/lib/perspective-camera/perspective-camera.mjs +3 -3
- package/esm2020/controls/lib/orbit-controls/orbit-controls.mjs +3 -3
- package/esm2020/loaders/lib/loader/loader.mjs +3 -3
- package/esm2020/materials/index.mjs +3 -1
- package/esm2020/materials/lib/mesh-distort-material/mesh-distort-material.mjs +3 -3
- package/esm2020/materials/lib/mesh-reflector-material/mesh-reflector-material.mjs +3 -3
- package/esm2020/materials/lib/mesh-refraction-material/mesh-refraction-material.mjs +157 -0
- package/esm2020/materials/lib/mesh-transmission-material/mesh-transmission-material.mjs +240 -0
- package/esm2020/materials/lib/mesh-wobble-material/mesh-wobble-material.mjs +3 -3
- package/esm2020/misc/lib/bake-shadows/bake-shadows.mjs +3 -3
- package/esm2020/misc/lib/fbo/fbo.mjs +5 -4
- package/esm2020/performance/lib/adaptive/adaptive-dpr.mjs +3 -3
- package/esm2020/performance/lib/adaptive/adaptive-events.mjs +3 -3
- package/esm2020/performance/lib/detailed/detailed.mjs +3 -3
- package/esm2020/performance/lib/stats/stats.mjs +3 -3
- package/esm2020/shaders/index.mjs +6 -1
- package/esm2020/shaders/lib/caustics-material/caustics-material.mjs +128 -0
- package/esm2020/shaders/lib/caustics-projection-material/caustics-projection-material.mjs +33 -0
- package/esm2020/shaders/lib/discard-material/discard-material.mjs +3 -0
- package/esm2020/shaders/lib/mesh-refraction-material/mesh-refraction-material.mjs +169 -0
- package/esm2020/shaders/lib/mesh-transmission-material/mesh-transmission-material.mjs +268 -0
- package/esm2020/staging/index.mjs +2 -1
- package/esm2020/staging/lib/accumulative-shadows/accumulative-shadows.mjs +6 -6
- package/esm2020/staging/lib/accumulative-shadows/progressive-light-map.mjs +2 -3
- package/esm2020/staging/lib/accumulative-shadows/randomized-lights.mjs +6 -6
- package/esm2020/staging/lib/bounds/bounds.mjs +3 -3
- package/esm2020/staging/lib/camera-shake/camera-shake.mjs +3 -3
- package/esm2020/staging/lib/caustics/caustics.mjs +364 -0
- package/esm2020/staging/lib/center/center.mjs +3 -3
- package/esm2020/staging/lib/cloud/cloud.mjs +3 -3
- package/esm2020/staging/lib/contact-shadows/contact-shadows.mjs +3 -3
- package/esm2020/staging/lib/environment/environment-cube.mjs +3 -3
- package/esm2020/staging/lib/environment/environment-ground.mjs +3 -3
- package/esm2020/staging/lib/environment/environment-inputs.mjs +3 -3
- package/esm2020/staging/lib/environment/environment-map.mjs +3 -3
- package/esm2020/staging/lib/environment/environment-portal.mjs +3 -3
- package/esm2020/staging/lib/environment/environment.mjs +6 -6
- package/esm2020/staging/lib/float/float.mjs +3 -3
- package/esm2020/staging/lib/sky/sky.mjs +3 -3
- package/esm2020/staging/lib/sparkles/sparkles.mjs +3 -3
- package/esm2020/staging/lib/spot-light/shadow-mesh-input.mjs +3 -3
- package/esm2020/staging/lib/spot-light/spot-light-input.mjs +3 -3
- package/esm2020/staging/lib/spot-light/spot-light-shadow-no-shader.mjs +3 -3
- package/esm2020/staging/lib/spot-light/spot-light-shadow-shader.mjs +3 -3
- package/esm2020/staging/lib/spot-light/spot-light-shadow.mjs +3 -3
- package/esm2020/staging/lib/spot-light/spot-light.mjs +3 -3
- package/esm2020/staging/lib/spot-light/volumetric-mesh.mjs +3 -3
- package/esm2020/staging/lib/stage/stage.mjs +6 -6
- package/esm2020/staging/lib/stars/stars.mjs +3 -3
- package/fesm2015/angular-three-soba-abstractions.mjs +145 -56
- package/fesm2015/angular-three-soba-abstractions.mjs.map +1 -1
- package/fesm2015/angular-three-soba-cameras.mjs +139 -16
- package/fesm2015/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2015/angular-three-soba-controls.mjs +3 -3
- package/fesm2015/angular-three-soba-loaders.mjs +3 -3
- package/fesm2015/angular-three-soba-materials.mjs +398 -11
- package/fesm2015/angular-three-soba-materials.mjs.map +1 -1
- package/fesm2015/angular-three-soba-misc.mjs +7 -6
- package/fesm2015/angular-three-soba-misc.mjs.map +1 -1
- package/fesm2015/angular-three-soba-performance.mjs +12 -12
- package/fesm2015/angular-three-soba-shaders.mjs +619 -31
- package/fesm2015/angular-three-soba-shaders.mjs.map +1 -1
- package/fesm2015/angular-three-soba-staging.mjs +450 -96
- package/fesm2015/angular-three-soba-staging.mjs.map +1 -1
- package/fesm2020/angular-three-soba-abstractions.mjs +145 -56
- package/fesm2020/angular-three-soba-abstractions.mjs.map +1 -1
- package/fesm2020/angular-three-soba-cameras.mjs +139 -16
- package/fesm2020/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2020/angular-three-soba-controls.mjs +3 -3
- package/fesm2020/angular-three-soba-loaders.mjs +3 -3
- package/fesm2020/angular-three-soba-materials.mjs +396 -11
- package/fesm2020/angular-three-soba-materials.mjs.map +1 -1
- package/fesm2020/angular-three-soba-misc.mjs +7 -6
- package/fesm2020/angular-three-soba-misc.mjs.map +1 -1
- package/fesm2020/angular-three-soba-performance.mjs +12 -12
- package/fesm2020/angular-three-soba-shaders.mjs +625 -34
- package/fesm2020/angular-three-soba-shaders.mjs.map +1 -1
- package/fesm2020/angular-three-soba-staging.mjs +449 -96
- package/fesm2020/angular-three-soba-staging.mjs.map +1 -1
- package/materials/index.d.ts +2 -0
- package/materials/lib/mesh-refraction-material/mesh-refraction-material.d.ts +28 -0
- package/materials/lib/mesh-transmission-material/mesh-transmission-material.d.ts +47 -0
- package/misc/lib/fbo/fbo.d.ts +8 -6
- package/package.json +4 -3
- package/plugin/package.json +1 -1
- package/shaders/index.d.ts +5 -0
- package/shaders/lib/caustics-material/caustics-material.d.ts +4 -0
- package/shaders/lib/caustics-projection-material/caustics-projection-material.d.ts +4 -0
- package/shaders/lib/discard-material/discard-material.d.ts +3 -0
- package/shaders/lib/mesh-refraction-material/mesh-refraction-material.d.ts +4 -0
- package/shaders/lib/mesh-transmission-material/mesh-transmission-material.d.ts +25 -0
- package/staging/index.d.ts +1 -0
- package/staging/lib/caustics/caustics.d.ts +48 -0
- package/staging/lib/environment/environment-cube.d.ts +1 -1
- package/staging/lib/environment/environment-ground.d.ts +1 -1
- 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.
|
|
37
|
-
NgtsMeshDistortMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
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.
|
|
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.
|
|
309
|
-
NgtsMeshReflectorMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
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.
|
|
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,389 @@ 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
|
+
const temp = {};
|
|
446
|
+
// Sampler2D and SamplerCube need different defines
|
|
447
|
+
const isCubeMap = isCubeTexture(envMap);
|
|
448
|
+
const w = (isCubeMap ? envMap.image[0]?.width : envMap.image.width) ?? 1024;
|
|
449
|
+
const cubeSize = w / 4;
|
|
450
|
+
const _lodMax = Math.floor(Math.log2(cubeSize));
|
|
451
|
+
const _cubeSize = Math.pow(2, _lodMax);
|
|
452
|
+
const width = 3 * Math.max(_cubeSize, 16 * 7);
|
|
453
|
+
const height = 4 * _cubeSize;
|
|
454
|
+
if (isCubeMap)
|
|
455
|
+
temp['ENVMAP_TYPE_CUBEM'] = '';
|
|
456
|
+
temp['CUBEUV_TEXEL_WIDTH'] = `${1.0 / width}`;
|
|
457
|
+
temp['CUBEUV_TEXEL_HEIGHT'] = `${1.0 / height}`;
|
|
458
|
+
temp['CUBEUV_MAX_MIP'] = `${_lodMax}.0`;
|
|
459
|
+
// Add defines from chromatic aberration
|
|
460
|
+
if (aberrationStrength > 0)
|
|
461
|
+
temp['CHROMATIC_ABERRATIONS'] = '';
|
|
462
|
+
if (fastChroma)
|
|
463
|
+
temp['FAST_CHROMA'] = '';
|
|
464
|
+
return temp;
|
|
465
|
+
})));
|
|
466
|
+
this.connect('resolution', this.store.select('size').pipe(map((size) => [size.width, size.height])));
|
|
467
|
+
injectBeforeRender(({ camera }) => {
|
|
468
|
+
if (this.materialRef.nativeElement) {
|
|
469
|
+
this.materialRef.nativeElement.viewMatrixInverse = camera.matrixWorld;
|
|
470
|
+
this.materialRef.nativeElement.projectionMatrixInverse = camera.projectionMatrixInverse;
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
ngOnInit() {
|
|
475
|
+
this.setupGeometry();
|
|
476
|
+
}
|
|
477
|
+
setupGeometry() {
|
|
478
|
+
this.hold(this.materialRef.$, (material) => {
|
|
479
|
+
const geometry = getLocalState(material).parent?.geometry;
|
|
480
|
+
if (geometry) {
|
|
481
|
+
material.bvh.updateFrom(new MeshBVH(geometry.toNonIndexed(), { lazyGeneration: false, strategy: SAH }));
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
NgtsMeshRefractionMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshRefractionMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
487
|
+
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: `
|
|
488
|
+
<ngt-mesh-refraction-material
|
|
489
|
+
*ngIf="defines$ | ngtPush as defines"
|
|
490
|
+
[ref]="materialRef"
|
|
491
|
+
[defines]="defines"
|
|
492
|
+
[resolution]="get('resolution')"
|
|
493
|
+
[aberrationStrength]="get('aberrationStrength')"
|
|
494
|
+
[envMap]="get('envMap')"
|
|
495
|
+
[bounces]="get('bounces')"
|
|
496
|
+
[ior]="get('ior')"
|
|
497
|
+
[fresnel]="get('fresnel')"
|
|
498
|
+
[color]="get('color')"
|
|
499
|
+
[fastChroma]="get('fastChroma')"
|
|
500
|
+
ngtCompound
|
|
501
|
+
attach="material"
|
|
502
|
+
>
|
|
503
|
+
<ng-content />
|
|
504
|
+
</ngt-mesh-refraction-material>
|
|
505
|
+
`, isInline: true, dependencies: [{ kind: "pipe", type: NgtPush, name: "ngtPush" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
506
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshRefractionMaterial, decorators: [{
|
|
507
|
+
type: Component,
|
|
508
|
+
args: [{
|
|
509
|
+
selector: 'ngts-mesh-refraction-material',
|
|
510
|
+
standalone: true,
|
|
511
|
+
template: `
|
|
512
|
+
<ngt-mesh-refraction-material
|
|
513
|
+
*ngIf="defines$ | ngtPush as defines"
|
|
514
|
+
[ref]="materialRef"
|
|
515
|
+
[defines]="defines"
|
|
516
|
+
[resolution]="get('resolution')"
|
|
517
|
+
[aberrationStrength]="get('aberrationStrength')"
|
|
518
|
+
[envMap]="get('envMap')"
|
|
519
|
+
[bounces]="get('bounces')"
|
|
520
|
+
[ior]="get('ior')"
|
|
521
|
+
[fresnel]="get('fresnel')"
|
|
522
|
+
[color]="get('color')"
|
|
523
|
+
[fastChroma]="get('fastChroma')"
|
|
524
|
+
ngtCompound
|
|
525
|
+
attach="material"
|
|
526
|
+
>
|
|
527
|
+
<ng-content />
|
|
528
|
+
</ngt-mesh-refraction-material>
|
|
529
|
+
`,
|
|
530
|
+
imports: [NgtPush, NgIf],
|
|
531
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
532
|
+
}]
|
|
533
|
+
}], ctorParameters: function () { return []; }, propDecorators: { materialRef: [{
|
|
534
|
+
type: Input
|
|
535
|
+
}], envMap: [{
|
|
536
|
+
type: Input
|
|
537
|
+
}], bounces: [{
|
|
538
|
+
type: Input
|
|
539
|
+
}], ior: [{
|
|
540
|
+
type: Input
|
|
541
|
+
}], fresnel: [{
|
|
542
|
+
type: Input
|
|
543
|
+
}], aberrationStrength: [{
|
|
544
|
+
type: Input
|
|
545
|
+
}], color: [{
|
|
546
|
+
type: Input
|
|
547
|
+
}], fastChroma: [{
|
|
548
|
+
type: Input
|
|
549
|
+
}] } });
|
|
550
|
+
|
|
551
|
+
extend({ MeshTransmissionMaterial });
|
|
552
|
+
class NgtsMeshTranmissionMaterial extends NgtRxStore {
|
|
553
|
+
/** transmissionSampler, you can use the threejs transmission sampler texture that is
|
|
554
|
+
* generated once for all transmissive materials. The upside is that it can be faster if you
|
|
555
|
+
* use multiple MeshPhysical and Transmission materials, the downside is that transmissive materials
|
|
556
|
+
* using this can't see other transparent or transmissive objects, default: false */
|
|
557
|
+
set transmissionSampler(transmissionSampler) {
|
|
558
|
+
this.set({ transmissionSampler });
|
|
559
|
+
}
|
|
560
|
+
/** Render the backside of the material (more cost, better results), default: false */
|
|
561
|
+
set backside(backside) {
|
|
562
|
+
this.set({ backside });
|
|
563
|
+
}
|
|
564
|
+
/** Backside thickness (when backside is true), default: 0 */
|
|
565
|
+
set backsideThickness(backsideThickness) {
|
|
566
|
+
this.set({ backsideThickness });
|
|
567
|
+
}
|
|
568
|
+
/** Resolution of the local buffer, default: undefined (fullscreen) */
|
|
569
|
+
set resolution(resolution) {
|
|
570
|
+
this.set({ resolution });
|
|
571
|
+
}
|
|
572
|
+
/** Resolution of the local buffer for backfaces, default: undefined (fullscreen) */
|
|
573
|
+
set backsideResolution(backsideResolution) {
|
|
574
|
+
this.set({ backsideResolution });
|
|
575
|
+
}
|
|
576
|
+
/** Refraction samples, default: 10 */
|
|
577
|
+
set samples(samples) {
|
|
578
|
+
this.set({ samples });
|
|
579
|
+
}
|
|
580
|
+
/** Buffer scene background (can be a texture, a cubetexture or a color), default: null */
|
|
581
|
+
set background(background) {
|
|
582
|
+
this.set({ background });
|
|
583
|
+
}
|
|
584
|
+
/* Transmission, default: 1 */
|
|
585
|
+
set transmission(transmission) {
|
|
586
|
+
this.set({ transmission });
|
|
587
|
+
}
|
|
588
|
+
/* Thickness (refraction), default: 0 */
|
|
589
|
+
set thickness(thickness) {
|
|
590
|
+
this.set({ thickness });
|
|
591
|
+
}
|
|
592
|
+
/* Roughness (blur), default: 0 */
|
|
593
|
+
set roughness(roughness) {
|
|
594
|
+
this.set({ roughness });
|
|
595
|
+
}
|
|
596
|
+
/* Chromatic aberration, default: 0.03 */
|
|
597
|
+
set chromaticAberration(chromaticAberration) {
|
|
598
|
+
this.set({ chromaticAberration });
|
|
599
|
+
}
|
|
600
|
+
/* Anisotropy, default: 0.1 */
|
|
601
|
+
set anisotropy(anisotropy) {
|
|
602
|
+
this.set({ anisotropy });
|
|
603
|
+
}
|
|
604
|
+
/* Distortion, default: 0 */
|
|
605
|
+
set distortion(distortion) {
|
|
606
|
+
this.set({ distortion });
|
|
607
|
+
}
|
|
608
|
+
/* Distortion scale, default: 0.5 */
|
|
609
|
+
set distortionScale(distortionScale) {
|
|
610
|
+
this.set({ distortionScale });
|
|
611
|
+
}
|
|
612
|
+
/* Temporal distortion (speed of movement), default: 0.0 */
|
|
613
|
+
set temporalDistortion(temporalDistortion) {
|
|
614
|
+
this.set({ temporalDistortion });
|
|
615
|
+
}
|
|
616
|
+
/** The scene rendered into a texture (use it to share a texture between materials), default: null */
|
|
617
|
+
set buffer(buffer) {
|
|
618
|
+
this.set({ buffer });
|
|
619
|
+
}
|
|
620
|
+
/** Internals */
|
|
621
|
+
set time(time) {
|
|
622
|
+
this.set({ time });
|
|
623
|
+
}
|
|
624
|
+
initialize() {
|
|
625
|
+
super.initialize();
|
|
626
|
+
this.set({
|
|
627
|
+
transmissionSampler: false,
|
|
628
|
+
backside: false,
|
|
629
|
+
side: THREE.FrontSide,
|
|
630
|
+
transmission: 1,
|
|
631
|
+
thickness: 0,
|
|
632
|
+
backsideThickness: 0,
|
|
633
|
+
samples: 10,
|
|
634
|
+
roughness: 0,
|
|
635
|
+
anisotropy: 0.1,
|
|
636
|
+
chromaticAberration: 0.03,
|
|
637
|
+
distortion: 0,
|
|
638
|
+
distortionScale: 0.5,
|
|
639
|
+
temporalDistortion: 0.0,
|
|
640
|
+
buffer: null,
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
constructor() {
|
|
644
|
+
super();
|
|
645
|
+
this.materialRef = injectNgtRef();
|
|
646
|
+
this.discardMaterial = new DiscardMaterial();
|
|
647
|
+
this.fboBackRef = injectNgtsFBO(() => combineLatest([this.select('backsideResolution'), this.select('resolution')]).pipe(map(([backsideResolution, resolution]) => backsideResolution || resolution)));
|
|
648
|
+
this.fboMainRef = injectNgtsFBO(() => this.select('resolution'));
|
|
649
|
+
let oldBg;
|
|
650
|
+
let oldTone;
|
|
651
|
+
let parent;
|
|
652
|
+
injectBeforeRender((state) => {
|
|
653
|
+
const { transmissionSampler, background, backside, backsideThickness, thickness, side } = this.get();
|
|
654
|
+
this.materialRef.nativeElement.time = state.clock.getElapsedTime();
|
|
655
|
+
// Render only if the buffer matches the built-in and no transmission sampler is set
|
|
656
|
+
if (this.materialRef.nativeElement.buffer === this.fboMainRef.nativeElement.texture &&
|
|
657
|
+
!transmissionSampler) {
|
|
658
|
+
parent = getLocalState(this.materialRef.nativeElement).parent;
|
|
659
|
+
if (parent) {
|
|
660
|
+
// Save defaults
|
|
661
|
+
oldTone = state.gl.toneMapping;
|
|
662
|
+
oldBg = state.scene.background;
|
|
663
|
+
// Switch off tonemapping lest it double tone maps
|
|
664
|
+
// Save the current background and set the HDR as the new BG
|
|
665
|
+
// Use discardmaterial, the parent will be invisible, but it's shadows will still be cast
|
|
666
|
+
state.gl.toneMapping = THREE.NoToneMapping;
|
|
667
|
+
if (background)
|
|
668
|
+
state.scene.background = background;
|
|
669
|
+
parent['material'] = this.discardMaterial;
|
|
670
|
+
if (backside) {
|
|
671
|
+
// Render into the backside buffer
|
|
672
|
+
state.gl.setRenderTarget(this.fboBackRef.nativeElement);
|
|
673
|
+
state.gl.render(state.scene, state.camera);
|
|
674
|
+
// And now prepare the material for the main render using the backside buffer
|
|
675
|
+
parent['material'] = this.materialRef.nativeElement;
|
|
676
|
+
parent['material'].buffer = this.fboBackRef.nativeElement.texture;
|
|
677
|
+
parent['material'].thickness = backsideThickness;
|
|
678
|
+
parent['material'].side = THREE.BackSide;
|
|
679
|
+
}
|
|
680
|
+
// Render into the main buffer
|
|
681
|
+
state.gl.setRenderTarget(this.fboMainRef.nativeElement);
|
|
682
|
+
state.gl.render(state.scene, state.camera);
|
|
683
|
+
parent['material'].thickness = thickness;
|
|
684
|
+
parent['material'].side = side;
|
|
685
|
+
parent['material'].buffer = this.fboMainRef.nativeElement.texture;
|
|
686
|
+
// Set old state back
|
|
687
|
+
state.scene.background = oldBg;
|
|
688
|
+
state.gl.setRenderTarget(null);
|
|
689
|
+
parent['material'] = this.materialRef.nativeElement;
|
|
690
|
+
state.gl.toneMapping = oldTone;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
ngOnInit() {
|
|
696
|
+
console.log(this.materialRef);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
NgtsMeshTranmissionMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshTranmissionMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
700
|
+
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: `
|
|
701
|
+
<ngt-mesh-transmission-material
|
|
702
|
+
*args="[get('samples'), get('transmissionSampler')]"
|
|
703
|
+
ngtCompound
|
|
704
|
+
[ref]="materialRef"
|
|
705
|
+
[buffer]="get('buffer') || fboMainRef.nativeElement?.texture"
|
|
706
|
+
[_transmission]="get('transmission')"
|
|
707
|
+
[transmission]="get('transmissionSampler') ? get('transmission') : 0"
|
|
708
|
+
[thickness]="get('thickness')"
|
|
709
|
+
[side]="get('side')"
|
|
710
|
+
[anisotropy]="get('anisotropy')"
|
|
711
|
+
[roughness]="get('roughness')"
|
|
712
|
+
[chromaticAberration]="get('chromaticAberration')"
|
|
713
|
+
[distortion]="get('distortion')"
|
|
714
|
+
[distortionScale]="get('distortionScale')"
|
|
715
|
+
[temporalDistortion]="get('temporalDistortion')"
|
|
716
|
+
[time]="get('time')"
|
|
717
|
+
/>
|
|
718
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
|
|
719
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshTranmissionMaterial, decorators: [{
|
|
720
|
+
type: Component,
|
|
721
|
+
args: [{
|
|
722
|
+
selector: 'ngts-mesh-transmission-material',
|
|
723
|
+
standalone: true,
|
|
724
|
+
template: `
|
|
725
|
+
<ngt-mesh-transmission-material
|
|
726
|
+
*args="[get('samples'), get('transmissionSampler')]"
|
|
727
|
+
ngtCompound
|
|
728
|
+
[ref]="materialRef"
|
|
729
|
+
[buffer]="get('buffer') || fboMainRef.nativeElement?.texture"
|
|
730
|
+
[_transmission]="get('transmission')"
|
|
731
|
+
[transmission]="get('transmissionSampler') ? get('transmission') : 0"
|
|
732
|
+
[thickness]="get('thickness')"
|
|
733
|
+
[side]="get('side')"
|
|
734
|
+
[anisotropy]="get('anisotropy')"
|
|
735
|
+
[roughness]="get('roughness')"
|
|
736
|
+
[chromaticAberration]="get('chromaticAberration')"
|
|
737
|
+
[distortion]="get('distortion')"
|
|
738
|
+
[distortionScale]="get('distortionScale')"
|
|
739
|
+
[temporalDistortion]="get('temporalDistortion')"
|
|
740
|
+
[time]="get('time')"
|
|
741
|
+
/>
|
|
742
|
+
`,
|
|
743
|
+
imports: [NgtArgs],
|
|
744
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
745
|
+
}]
|
|
746
|
+
}], ctorParameters: function () { return []; }, propDecorators: { materialRef: [{
|
|
747
|
+
type: Input
|
|
748
|
+
}], transmissionSampler: [{
|
|
749
|
+
type: Input
|
|
750
|
+
}], backside: [{
|
|
751
|
+
type: Input
|
|
752
|
+
}], backsideThickness: [{
|
|
753
|
+
type: Input
|
|
754
|
+
}], resolution: [{
|
|
755
|
+
type: Input
|
|
756
|
+
}], backsideResolution: [{
|
|
757
|
+
type: Input
|
|
758
|
+
}], samples: [{
|
|
759
|
+
type: Input
|
|
760
|
+
}], background: [{
|
|
761
|
+
type: Input
|
|
762
|
+
}], transmission: [{
|
|
763
|
+
type: Input
|
|
764
|
+
}], thickness: [{
|
|
765
|
+
type: Input
|
|
766
|
+
}], roughness: [{
|
|
767
|
+
type: Input
|
|
768
|
+
}], chromaticAberration: [{
|
|
769
|
+
type: Input
|
|
770
|
+
}], anisotropy: [{
|
|
771
|
+
type: Input
|
|
772
|
+
}], distortion: [{
|
|
773
|
+
type: Input
|
|
774
|
+
}], distortionScale: [{
|
|
775
|
+
type: Input
|
|
776
|
+
}], temporalDistortion: [{
|
|
777
|
+
type: Input
|
|
778
|
+
}], buffer: [{
|
|
779
|
+
type: Input
|
|
780
|
+
}], time: [{
|
|
781
|
+
type: Input
|
|
782
|
+
}] } });
|
|
783
|
+
|
|
399
784
|
extend({ MeshWobbleMaterial });
|
|
400
785
|
class NgtsMeshWobbleMaterial extends NgtRxStore {
|
|
401
786
|
set time(time) {
|
|
@@ -420,8 +805,8 @@ class NgtsMeshWobbleMaterial extends NgtRxStore {
|
|
|
420
805
|
});
|
|
421
806
|
}
|
|
422
807
|
}
|
|
423
|
-
NgtsMeshWobbleMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
424
|
-
NgtsMeshWobbleMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
808
|
+
NgtsMeshWobbleMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshWobbleMaterial, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
809
|
+
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
810
|
<ngt-primitive
|
|
426
811
|
*args="[material]"
|
|
427
812
|
[ref]="materialRef"
|
|
@@ -431,7 +816,7 @@ NgtsMeshWobbleMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0",
|
|
|
431
816
|
ngtCompound
|
|
432
817
|
/>
|
|
433
818
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
|
|
434
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
819
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsMeshWobbleMaterial, decorators: [{
|
|
435
820
|
type: Component,
|
|
436
821
|
args: [{
|
|
437
822
|
selector: 'ngts-mesh-wobble-material',
|
|
@@ -463,5 +848,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
|
|
|
463
848
|
* Generated bundle index. Do not edit.
|
|
464
849
|
*/
|
|
465
850
|
|
|
466
|
-
export { NgtsMeshDistortMaterial, NgtsMeshReflectorMaterial, NgtsMeshWobbleMaterial };
|
|
851
|
+
export { NgtsMeshDistortMaterial, NgtsMeshReflectorMaterial, NgtsMeshRefractionMaterial, NgtsMeshTranmissionMaterial, NgtsMeshWobbleMaterial };
|
|
467
852
|
//# sourceMappingURL=angular-three-soba-materials.mjs.map
|