angular-three-soba 1.10.0 → 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/edges/edges.mjs +95 -0
- package/esm2020/cameras/index.mjs +2 -1
- package/esm2020/cameras/lib/camera/camera-content.mjs +1 -1
- package/esm2020/cameras/lib/cube-camera/cube-camera.mjs +130 -0
- package/esm2020/materials/index.mjs +3 -1
- 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/misc/lib/fbo/fbo.mjs +5 -4
- package/esm2020/shaders/index.mjs +5 -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-transmission-material/mesh-transmission-material.mjs +268 -0
- package/esm2020/staging/index.mjs +2 -1
- package/esm2020/staging/lib/accumulative-shadows/progressive-light-map.mjs +2 -3
- package/esm2020/staging/lib/caustics/caustics.mjs +364 -0
- package/fesm2015/angular-three-soba-abstractions.mjs +91 -2
- package/fesm2015/angular-three-soba-abstractions.mjs.map +1 -1
- package/fesm2015/angular-three-soba-cameras.mjs +127 -4
- package/fesm2015/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2015/angular-three-soba-materials.mjs +389 -2
- package/fesm2015/angular-three-soba-materials.mjs.map +1 -1
- package/fesm2015/angular-three-soba-misc.mjs +4 -3
- package/fesm2015/angular-three-soba-misc.mjs.map +1 -1
- package/fesm2015/angular-three-soba-shaders.mjs +454 -31
- package/fesm2015/angular-three-soba-shaders.mjs.map +1 -1
- package/fesm2015/angular-three-soba-staging.mjs +363 -9
- package/fesm2015/angular-three-soba-staging.mjs.map +1 -1
- package/fesm2020/angular-three-soba-abstractions.mjs +91 -2
- package/fesm2020/angular-three-soba-abstractions.mjs.map +1 -1
- package/fesm2020/angular-three-soba-cameras.mjs +127 -4
- package/fesm2020/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2020/angular-three-soba-materials.mjs +387 -2
- package/fesm2020/angular-three-soba-materials.mjs.map +1 -1
- package/fesm2020/angular-three-soba-misc.mjs +4 -3
- package/fesm2020/angular-three-soba-misc.mjs.map +1 -1
- package/fesm2020/angular-three-soba-shaders.mjs +460 -34
- package/fesm2020/angular-three-soba-shaders.mjs.map +1 -1
- package/fesm2020/angular-three-soba-staging.mjs +362 -9
- 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 +2 -2
- package/plugin/package.json +1 -1
- package/shaders/index.d.ts +4 -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-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,13 +1,14 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, Directive, Component, CUSTOM_ELEMENTS_SCHEMA, Input, EventEmitter, Output, TemplateRef, ContentChild
|
|
2
|
+
import { InjectionToken, inject, Directive, Component, CUSTOM_ELEMENTS_SCHEMA, Input, EventEmitter, Output, ChangeDetectorRef, TemplateRef, ContentChild } from '@angular/core';
|
|
3
3
|
import { extend, NgtStore, getLocalState, NgtRxStore, injectNgtRef, NgtArgs, NgtRepeat, is, injectBeforeRender, NgtPush, injectNgtDestroy, injectNgtLoader, startWithUndefined, prepare, NgtPortal, NgtPortalContent, createRunInContext, checkUpdate } from 'angular-three';
|
|
4
|
-
import { shaderMaterial, SpotLightMaterial } from 'angular-three-soba/shaders';
|
|
5
|
-
import { Subject, combineLatest, switchMap, isObservable, of, debounceTime,
|
|
4
|
+
import { DiscardMaterial, shaderMaterial, CausticsProjectionMaterial, CausticsMaterial, SpotLightMaterial } from 'angular-three-soba/shaders';
|
|
5
|
+
import { Subject, combineLatest, switchMap, map, isObservable, of, debounceTime, 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, SpotLight, SpotLightHelper, AmbientLight, PointLight, Spherical, AdditiveBlending } from 'three';
|
|
8
|
-
import { SimplexNoise, HorizontalBlurShader, VerticalBlurShader, RGBELoader, GroundProjectedEnv, Sky
|
|
9
|
-
import {
|
|
10
|
-
import { NgtsBillboard } from 'angular-three-soba/abstractions';
|
|
7
|
+
import { Group, Mesh, PlaneGeometry, DirectionalLight, OrthographicCamera, Vector2, Scene, LineBasicMaterial, 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, FullScreenQuad, HorizontalBlurShader, VerticalBlurShader, RGBELoader, GroundProjectedEnv, Sky } from 'three-stdlib';
|
|
9
|
+
import { NgIf, NgFor, NgTemplateOutlet } from '@angular/common';
|
|
10
|
+
import { NgtsEdges, NgtsBillboard } from 'angular-three-soba/abstractions';
|
|
11
|
+
import { injectNgtsFBO } from 'angular-three-soba/misc';
|
|
11
12
|
import { injectNgtsTextureLoader } from 'angular-three-soba/loaders';
|
|
12
13
|
|
|
13
14
|
function isLight(object) {
|
|
@@ -16,7 +17,6 @@ function isLight(object) {
|
|
|
16
17
|
function isGeometry(object) {
|
|
17
18
|
return !!object.geometry;
|
|
18
19
|
}
|
|
19
|
-
const DiscardMaterial = shaderMaterial({}, 'void main() { gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }', 'void main() { discard; }');
|
|
20
20
|
class ProgressiveLightMap {
|
|
21
21
|
constructor(renderer, scene, res = 1024) {
|
|
22
22
|
this.renderer = renderer;
|
|
@@ -972,6 +972,359 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImpor
|
|
|
972
972
|
type: Input
|
|
973
973
|
}] } });
|
|
974
974
|
|
|
975
|
+
extend({ Group, Scene, Mesh, PlaneGeometry, OrthographicCamera, CausticsProjectionMaterial, LineBasicMaterial });
|
|
976
|
+
const NORMALPROPS = {
|
|
977
|
+
depth: true,
|
|
978
|
+
minFilter: THREE.LinearFilter,
|
|
979
|
+
magFilter: THREE.LinearFilter,
|
|
980
|
+
encoding: THREE.LinearEncoding,
|
|
981
|
+
type: THREE.UnsignedByteType,
|
|
982
|
+
};
|
|
983
|
+
const CAUSTICPROPS = {
|
|
984
|
+
minFilter: THREE.LinearMipmapLinearFilter,
|
|
985
|
+
magFilter: THREE.LinearFilter,
|
|
986
|
+
encoding: THREE.LinearEncoding,
|
|
987
|
+
format: THREE.RGBAFormat,
|
|
988
|
+
type: THREE.FloatType,
|
|
989
|
+
generateMipmaps: true,
|
|
990
|
+
};
|
|
991
|
+
function createNormalMaterial(side = THREE.FrontSide) {
|
|
992
|
+
const viewMatrix = { value: new THREE.Matrix4() };
|
|
993
|
+
return Object.assign(new THREE.MeshNormalMaterial({ side }), {
|
|
994
|
+
viewMatrix,
|
|
995
|
+
onBeforeCompile: (shader) => {
|
|
996
|
+
shader.uniforms.viewMatrix = viewMatrix;
|
|
997
|
+
shader.fragmentShader =
|
|
998
|
+
`vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
999
|
+
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
1000
|
+
}\n` +
|
|
1001
|
+
shader.fragmentShader.replace('#include <normal_fragment_maps>', `#include <normal_fragment_maps>
|
|
1002
|
+
normal = inverseTransformDirection( normal, viewMatrix );\n`);
|
|
1003
|
+
},
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
class NgtsCaustics extends NgtRxStore {
|
|
1007
|
+
constructor() {
|
|
1008
|
+
super(...arguments);
|
|
1009
|
+
this.CustomBlending = THREE.CustomBlending;
|
|
1010
|
+
this.OneFactor = THREE.OneFactor;
|
|
1011
|
+
this.SrcAlphaFactor = THREE.SrcAlphaFactor;
|
|
1012
|
+
this.Math = Math;
|
|
1013
|
+
this.planeRef = injectNgtRef();
|
|
1014
|
+
this.sceneRef = injectNgtRef();
|
|
1015
|
+
this.cameraRef = injectNgtRef();
|
|
1016
|
+
this.causticsRef = injectNgtRef();
|
|
1017
|
+
this.normalTargetFbo = injectNgtsFBO(() => this.select('resolution').pipe(map((resolution) => ({ width: resolution, height: resolution, settings: NORMALPROPS }))));
|
|
1018
|
+
this.normalTargetBFbo = injectNgtsFBO(() => this.select('resolution').pipe(map((resolution) => ({ width: resolution, height: resolution, settings: NORMALPROPS }))));
|
|
1019
|
+
this.causticsTargetFbo = injectNgtsFBO(() => this.select('resolution').pipe(map((resolution) => ({ width: resolution, height: resolution, settings: CAUSTICPROPS }))));
|
|
1020
|
+
this.causticsTargetBFbo = injectNgtsFBO(() => this.select('resolution').pipe(map((resolution) => ({ width: resolution, height: resolution, settings: CAUSTICPROPS }))));
|
|
1021
|
+
this.store = inject(NgtStore);
|
|
1022
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
1023
|
+
}
|
|
1024
|
+
/** How many frames it will render, set it to Infinity for runtime, default: 1 */
|
|
1025
|
+
set frames(frames) {
|
|
1026
|
+
this.set({ frames });
|
|
1027
|
+
}
|
|
1028
|
+
/** Enables visual cues to help you stage your scene, default: false */
|
|
1029
|
+
set debug(debug) {
|
|
1030
|
+
this.set({ debug });
|
|
1031
|
+
}
|
|
1032
|
+
/** Will display caustics only and skip the models, default: false */
|
|
1033
|
+
set causticsOnly(causticsOnly) {
|
|
1034
|
+
this.set({ causticsOnly });
|
|
1035
|
+
}
|
|
1036
|
+
/** Will include back faces and enable the backsideIOR prop, default: false */
|
|
1037
|
+
set backside(backside) {
|
|
1038
|
+
this.set({ backside });
|
|
1039
|
+
}
|
|
1040
|
+
/** The IOR refraction index, default: 1.1 */
|
|
1041
|
+
set ior(ior) {
|
|
1042
|
+
this.set({ ior });
|
|
1043
|
+
}
|
|
1044
|
+
/** The IOR refraction index for back faces (only available when backside is enabled), default: 1.1 */
|
|
1045
|
+
set backsideIOR(backsideIOR) {
|
|
1046
|
+
this.set({ backsideIOR });
|
|
1047
|
+
}
|
|
1048
|
+
/** The texel size, default: 0.3125 */
|
|
1049
|
+
set worldRadius(worldRadius) {
|
|
1050
|
+
this.set({ worldRadius });
|
|
1051
|
+
}
|
|
1052
|
+
/** Intensity of the prjected caustics, default: 0.05 */
|
|
1053
|
+
set intensity(intensity) {
|
|
1054
|
+
this.set({ intensity });
|
|
1055
|
+
}
|
|
1056
|
+
/** Caustics color, default: white */
|
|
1057
|
+
set color(color) {
|
|
1058
|
+
this.set({ color });
|
|
1059
|
+
}
|
|
1060
|
+
/** Buffer resolution, default: 2048 */
|
|
1061
|
+
set resolution(resolution) {
|
|
1062
|
+
this.set({ resolution });
|
|
1063
|
+
}
|
|
1064
|
+
/** Camera position, it will point towards the contents bounds center, default: [5, 5, 5] */
|
|
1065
|
+
set lightSource(lightSource) {
|
|
1066
|
+
this.set({ lightSource });
|
|
1067
|
+
}
|
|
1068
|
+
initialize() {
|
|
1069
|
+
this.set({
|
|
1070
|
+
frames: 1,
|
|
1071
|
+
ior: 1.1,
|
|
1072
|
+
color: 'white',
|
|
1073
|
+
causticsOnly: false,
|
|
1074
|
+
backside: false,
|
|
1075
|
+
backsideIOR: 1.1,
|
|
1076
|
+
worldRadius: 0.3125,
|
|
1077
|
+
intensity: 0.05,
|
|
1078
|
+
resolution: 2024,
|
|
1079
|
+
lightSource: [5, 5, 5],
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
ngOnInit() {
|
|
1083
|
+
this.updateWorldMatrix();
|
|
1084
|
+
this.setBeforeRender();
|
|
1085
|
+
}
|
|
1086
|
+
updateWorldMatrix() {
|
|
1087
|
+
this.hold(combineLatest([this.sceneRef.children$(), this.causticsRef.$, this.causticsRef.children$(), this.select()]), () => {
|
|
1088
|
+
if (this.causticsRef.nativeElement) {
|
|
1089
|
+
this.causticsRef.nativeElement.updateWorldMatrix(false, true);
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
setBeforeRender() {
|
|
1094
|
+
const causticsMaterial = new CausticsMaterial();
|
|
1095
|
+
const causticsQuad = new FullScreenQuad(causticsMaterial);
|
|
1096
|
+
const normalMaterial = createNormalMaterial();
|
|
1097
|
+
const normalMaterialB = createNormalMaterial(THREE.BackSide);
|
|
1098
|
+
this.effect(combineLatest([
|
|
1099
|
+
this.sceneRef.$,
|
|
1100
|
+
this.sceneRef.children$('both'),
|
|
1101
|
+
this.causticsRef.$,
|
|
1102
|
+
this.cameraRef.$,
|
|
1103
|
+
this.planeRef.$,
|
|
1104
|
+
this.planeRef.children$('both'),
|
|
1105
|
+
this.normalTargetFbo.$,
|
|
1106
|
+
this.normalTargetBFbo.$,
|
|
1107
|
+
this.causticsTargetFbo.$,
|
|
1108
|
+
this.causticsTargetBFbo.$,
|
|
1109
|
+
]), ([scene, children, caustics, camera, plane, , normalTarget, normalTargetB, causticsTarget, causticsTargetB,]) => {
|
|
1110
|
+
const v = new THREE.Vector3();
|
|
1111
|
+
const lpF = new THREE.Frustum();
|
|
1112
|
+
const lpM = new THREE.Matrix4();
|
|
1113
|
+
const lpP = new THREE.Plane();
|
|
1114
|
+
const lightDir = new THREE.Vector3();
|
|
1115
|
+
const lightDirInv = new THREE.Vector3();
|
|
1116
|
+
const bounds = new THREE.Box3();
|
|
1117
|
+
const focusPos = new THREE.Vector3();
|
|
1118
|
+
let count = 0;
|
|
1119
|
+
caustics.updateWorldMatrix(false, true);
|
|
1120
|
+
if (children.length > 1) {
|
|
1121
|
+
return this.store.get('internal').subscribe(({ gl }) => {
|
|
1122
|
+
const { frames, lightSource, resolution, worldRadius, intensity, backside, backsideIOR, ior, causticsOnly, debug, } = this.get();
|
|
1123
|
+
if (frames === Infinity || count++ < frames) {
|
|
1124
|
+
if (Array.isArray(lightSource))
|
|
1125
|
+
lightDir.fromArray(lightSource).normalize();
|
|
1126
|
+
else
|
|
1127
|
+
lightDir.copy(caustics.worldToLocal(lightSource.nativeElement.getWorldPosition(v)).normalize());
|
|
1128
|
+
lightDirInv.copy(lightDir).multiplyScalar(-1);
|
|
1129
|
+
let boundsVertices = [];
|
|
1130
|
+
scene.parent?.matrixWorld.identity();
|
|
1131
|
+
bounds.setFromObject(scene, true);
|
|
1132
|
+
boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.min.y, bounds.min.z));
|
|
1133
|
+
boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.min.y, bounds.max.z));
|
|
1134
|
+
boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.max.y, bounds.min.z));
|
|
1135
|
+
boundsVertices.push(new THREE.Vector3(bounds.min.x, bounds.max.y, bounds.max.z));
|
|
1136
|
+
boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.min.y, bounds.min.z));
|
|
1137
|
+
boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.min.y, bounds.max.z));
|
|
1138
|
+
boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.max.y, bounds.min.z));
|
|
1139
|
+
boundsVertices.push(new THREE.Vector3(bounds.max.x, bounds.max.y, bounds.max.z));
|
|
1140
|
+
const worldVerts = boundsVertices.map((v) => v.clone());
|
|
1141
|
+
bounds.getCenter(focusPos);
|
|
1142
|
+
boundsVertices = boundsVertices.map((v) => v.clone().sub(focusPos));
|
|
1143
|
+
const lightPlane = lpP.set(lightDirInv, 0);
|
|
1144
|
+
const projectedVerts = boundsVertices.map((v) => lightPlane.projectPoint(v, new THREE.Vector3()));
|
|
1145
|
+
const centralVert = projectedVerts
|
|
1146
|
+
.reduce((a, b) => a.add(b), v.set(0, 0, 0))
|
|
1147
|
+
.divideScalar(projectedVerts.length);
|
|
1148
|
+
const radius = projectedVerts
|
|
1149
|
+
.map((v) => v.distanceTo(centralVert))
|
|
1150
|
+
.reduce((a, b) => Math.max(a, b));
|
|
1151
|
+
const dirLength = boundsVertices
|
|
1152
|
+
.map((x) => x.dot(lightDir))
|
|
1153
|
+
.reduce((a, b) => Math.max(a, b));
|
|
1154
|
+
// Shadows
|
|
1155
|
+
camera.position.copy(lightDir.clone().multiplyScalar(dirLength).add(focusPos));
|
|
1156
|
+
camera.lookAt(scene.localToWorld(focusPos.clone()));
|
|
1157
|
+
const dirMatrix = lpM.lookAt(camera.position, focusPos, v.set(0, 1, 0));
|
|
1158
|
+
camera.left = -radius;
|
|
1159
|
+
camera.right = radius;
|
|
1160
|
+
camera.top = radius;
|
|
1161
|
+
camera.bottom = -radius;
|
|
1162
|
+
const yOffset = v.set(0, radius, 0).applyMatrix4(dirMatrix);
|
|
1163
|
+
const yTime = (camera.position.y + yOffset.y) / lightDir.y;
|
|
1164
|
+
camera.near = 0.1;
|
|
1165
|
+
camera.far = yTime;
|
|
1166
|
+
camera.updateProjectionMatrix();
|
|
1167
|
+
camera.updateMatrixWorld();
|
|
1168
|
+
// Now find size of ground plane
|
|
1169
|
+
const groundProjectedCoords = worldVerts.map((v) => v.add(lightDir.clone().multiplyScalar(-v.y / lightDir.y)));
|
|
1170
|
+
const centerPos = groundProjectedCoords
|
|
1171
|
+
.reduce((a, b) => a.add(b), v.set(0, 0, 0))
|
|
1172
|
+
.divideScalar(groundProjectedCoords.length);
|
|
1173
|
+
const maxSize = 2 *
|
|
1174
|
+
groundProjectedCoords
|
|
1175
|
+
.map((v) => Math.hypot(v.x - centerPos.x, v.z - centerPos.z))
|
|
1176
|
+
.reduce((a, b) => Math.max(a, b));
|
|
1177
|
+
plane.scale.setScalar(maxSize);
|
|
1178
|
+
plane.position.copy(centerPos);
|
|
1179
|
+
// if (debug) helper.current?.update();
|
|
1180
|
+
// Inject uniforms
|
|
1181
|
+
normalMaterialB.viewMatrix.value = normalMaterial.viewMatrix.value =
|
|
1182
|
+
camera.matrixWorldInverse;
|
|
1183
|
+
const dirLightNearPlane = lpF.setFromProjectionMatrix(lpM.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse)).planes[4];
|
|
1184
|
+
causticsMaterial.cameraMatrixWorld = camera.matrixWorld;
|
|
1185
|
+
causticsMaterial.cameraProjectionMatrixInv = camera.projectionMatrixInverse;
|
|
1186
|
+
causticsMaterial.lightDir = lightDirInv;
|
|
1187
|
+
causticsMaterial.lightPlaneNormal = dirLightNearPlane.normal;
|
|
1188
|
+
causticsMaterial.lightPlaneConstant = dirLightNearPlane.constant;
|
|
1189
|
+
causticsMaterial.near = camera.near;
|
|
1190
|
+
causticsMaterial.far = camera.far;
|
|
1191
|
+
causticsMaterial.resolution = resolution;
|
|
1192
|
+
causticsMaterial.size = radius;
|
|
1193
|
+
causticsMaterial.intensity = intensity;
|
|
1194
|
+
causticsMaterial.worldRadius = worldRadius;
|
|
1195
|
+
// Switch the scene on
|
|
1196
|
+
scene.visible = true;
|
|
1197
|
+
// Render front face normals
|
|
1198
|
+
gl.setRenderTarget(normalTarget);
|
|
1199
|
+
gl.clear();
|
|
1200
|
+
scene.overrideMaterial = normalMaterial;
|
|
1201
|
+
gl.render(scene, camera);
|
|
1202
|
+
// Render back face normals, if enabled
|
|
1203
|
+
gl.setRenderTarget(normalTargetB);
|
|
1204
|
+
gl.clear();
|
|
1205
|
+
if (backside) {
|
|
1206
|
+
scene.overrideMaterial = normalMaterialB;
|
|
1207
|
+
gl.render(scene, camera);
|
|
1208
|
+
}
|
|
1209
|
+
// Remove the override material
|
|
1210
|
+
scene.overrideMaterial = null;
|
|
1211
|
+
// Render front face caustics
|
|
1212
|
+
causticsMaterial.ior = ior;
|
|
1213
|
+
// @ts-ignore
|
|
1214
|
+
plane.material.lightProjMatrix = camera.projectionMatrix;
|
|
1215
|
+
// @ts-ignore
|
|
1216
|
+
plane.material.lightViewMatrix = camera.matrixWorldInverse;
|
|
1217
|
+
causticsMaterial.normalTexture = normalTarget.texture;
|
|
1218
|
+
causticsMaterial.depthTexture = normalTarget.depthTexture;
|
|
1219
|
+
gl.setRenderTarget(causticsTarget);
|
|
1220
|
+
gl.clear();
|
|
1221
|
+
causticsQuad.render(gl);
|
|
1222
|
+
// Render back face caustics, if enabled
|
|
1223
|
+
causticsMaterial.ior = backsideIOR;
|
|
1224
|
+
causticsMaterial.normalTexture = normalTargetB.texture;
|
|
1225
|
+
causticsMaterial.depthTexture = normalTargetB.depthTexture;
|
|
1226
|
+
gl.setRenderTarget(causticsTargetB);
|
|
1227
|
+
gl.clear();
|
|
1228
|
+
if (backside)
|
|
1229
|
+
causticsQuad.render(gl);
|
|
1230
|
+
// Reset render target
|
|
1231
|
+
gl.setRenderTarget(null);
|
|
1232
|
+
// Switch the scene off if caustics is all that's wanted
|
|
1233
|
+
if (causticsOnly)
|
|
1234
|
+
scene.visible = false;
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
NgtsCaustics.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsCaustics, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1242
|
+
NgtsCaustics.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtsCaustics, isStandalone: true, selector: "ngts-caustics", inputs: { causticsRef: "causticsRef", frames: "frames", debug: "debug", causticsOnly: "causticsOnly", backside: "backside", ior: "ior", backsideIOR: "backsideIOR", worldRadius: "worldRadius", intensity: "intensity", color: "color", resolution: "resolution", lightSource: "lightSource" }, usesInheritance: true, ngImport: i0, template: `
|
|
1243
|
+
<ngt-group [ref]="causticsRef" ngtCompound>
|
|
1244
|
+
<ngt-scene [ref]="sceneRef">
|
|
1245
|
+
<ngt-orthographic-camera [ref]="cameraRef" [up]="[0, 1, 0]" />
|
|
1246
|
+
<ng-content />
|
|
1247
|
+
</ngt-scene>
|
|
1248
|
+
<ngt-mesh [renderOrder]="2" [ref]="planeRef" [rotation]="[-Math.PI / 2, 0, 0]">
|
|
1249
|
+
<ngt-plane-geometry />
|
|
1250
|
+
<ngt-caustics-projection-material
|
|
1251
|
+
*ngIf="causticsTargetFbo.nativeElement && causticsTargetBFbo.nativeElement"
|
|
1252
|
+
[transparent]="true"
|
|
1253
|
+
[color]="get('color')"
|
|
1254
|
+
[causticsTexture]="causticsTargetFbo.nativeElement.texture"
|
|
1255
|
+
[causticsTextureB]="causticsTargetBFbo.nativeElement.texture"
|
|
1256
|
+
[blending]="CustomBlending"
|
|
1257
|
+
[blendSrc]="OneFactor"
|
|
1258
|
+
[blendDst]="SrcAlphaFactor"
|
|
1259
|
+
[depthWrite]="false"
|
|
1260
|
+
/>
|
|
1261
|
+
|
|
1262
|
+
<ngts-edges *ngIf="get('debug')" [withChildren]="true">
|
|
1263
|
+
<ngt-line-basic-material color="#ffff00" [toneMapped]="false" />
|
|
1264
|
+
</ngts-edges>
|
|
1265
|
+
</ngt-mesh>
|
|
1266
|
+
</ngt-group>
|
|
1267
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: NgtsEdges, selector: "ngts-edges", inputs: ["edgesRef", "threshold", "color", "geometry", "userData", "withChildren"] }] });
|
|
1268
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtsCaustics, decorators: [{
|
|
1269
|
+
type: Component,
|
|
1270
|
+
args: [{
|
|
1271
|
+
selector: 'ngts-caustics',
|
|
1272
|
+
standalone: true,
|
|
1273
|
+
template: `
|
|
1274
|
+
<ngt-group [ref]="causticsRef" ngtCompound>
|
|
1275
|
+
<ngt-scene [ref]="sceneRef">
|
|
1276
|
+
<ngt-orthographic-camera [ref]="cameraRef" [up]="[0, 1, 0]" />
|
|
1277
|
+
<ng-content />
|
|
1278
|
+
</ngt-scene>
|
|
1279
|
+
<ngt-mesh [renderOrder]="2" [ref]="planeRef" [rotation]="[-Math.PI / 2, 0, 0]">
|
|
1280
|
+
<ngt-plane-geometry />
|
|
1281
|
+
<ngt-caustics-projection-material
|
|
1282
|
+
*ngIf="causticsTargetFbo.nativeElement && causticsTargetBFbo.nativeElement"
|
|
1283
|
+
[transparent]="true"
|
|
1284
|
+
[color]="get('color')"
|
|
1285
|
+
[causticsTexture]="causticsTargetFbo.nativeElement.texture"
|
|
1286
|
+
[causticsTextureB]="causticsTargetBFbo.nativeElement.texture"
|
|
1287
|
+
[blending]="CustomBlending"
|
|
1288
|
+
[blendSrc]="OneFactor"
|
|
1289
|
+
[blendDst]="SrcAlphaFactor"
|
|
1290
|
+
[depthWrite]="false"
|
|
1291
|
+
/>
|
|
1292
|
+
|
|
1293
|
+
<ngts-edges *ngIf="get('debug')" [withChildren]="true">
|
|
1294
|
+
<ngt-line-basic-material color="#ffff00" [toneMapped]="false" />
|
|
1295
|
+
</ngts-edges>
|
|
1296
|
+
</ngt-mesh>
|
|
1297
|
+
</ngt-group>
|
|
1298
|
+
`,
|
|
1299
|
+
imports: [NgIf, NgtsEdges],
|
|
1300
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
1301
|
+
}]
|
|
1302
|
+
}], propDecorators: { causticsRef: [{
|
|
1303
|
+
type: Input
|
|
1304
|
+
}], frames: [{
|
|
1305
|
+
type: Input
|
|
1306
|
+
}], debug: [{
|
|
1307
|
+
type: Input
|
|
1308
|
+
}], causticsOnly: [{
|
|
1309
|
+
type: Input
|
|
1310
|
+
}], backside: [{
|
|
1311
|
+
type: Input
|
|
1312
|
+
}], ior: [{
|
|
1313
|
+
type: Input
|
|
1314
|
+
}], backsideIOR: [{
|
|
1315
|
+
type: Input
|
|
1316
|
+
}], worldRadius: [{
|
|
1317
|
+
type: Input
|
|
1318
|
+
}], intensity: [{
|
|
1319
|
+
type: Input
|
|
1320
|
+
}], color: [{
|
|
1321
|
+
type: Input
|
|
1322
|
+
}], resolution: [{
|
|
1323
|
+
type: Input
|
|
1324
|
+
}], lightSource: [{
|
|
1325
|
+
type: Input
|
|
1326
|
+
}] } });
|
|
1327
|
+
|
|
975
1328
|
extend({ Group });
|
|
976
1329
|
class NgtsCenter extends NgtRxStore {
|
|
977
1330
|
constructor() {
|
|
@@ -3485,5 +3838,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImpor
|
|
|
3485
3838
|
* Generated bundle index. Do not edit.
|
|
3486
3839
|
*/
|
|
3487
3840
|
|
|
3488
|
-
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 };
|
|
3841
|
+
export { NGTS_BOUNDS_API, NGTS_SPOT_LIGHT_API, NgtsAccumulativeShadows, NgtsBounds, NgtsCameraShake, NgtsCaustics, NgtsCenter, NgtsCloud, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentContent, NgtsFloat, NgtsRandomizedLights, NgtsSky, NgtsSparkles, NgtsSpotLight, NgtsSpotLightShadow, NgtsStage, NgtsStageRefit, NgtsStars, calcPosFromAngles, ngtsEnvironmentPresetsObj };
|
|
3489
3842
|
//# sourceMappingURL=angular-three-soba-staging.mjs.map
|