|
1 | 1 | import { NgIf } from '@angular/common';
|
2 |
| -import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, inject, Input, OnInit } from '@angular/core'; |
| 2 | +import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, inject, Input, OnInit } from '@angular/core'; |
3 | 3 | import { extend, injectNgtRef, NgtRxStore, NgtStore } from 'angular-three';
|
4 | 4 | import { NgtsEdges } from 'angular-three-soba/abstractions';
|
5 | 5 | import { injectNgtsFBO } from 'angular-three-soba/misc';
|
@@ -189,7 +189,6 @@ export class NgtsCaustics extends NgtRxStore implements OnInit {
|
189 | 189 | );
|
190 | 190 |
|
191 | 191 | private readonly store = inject(NgtStore);
|
192 |
| - private readonly cdr = inject(ChangeDetectorRef); |
193 | 192 |
|
194 | 193 | override initialize(): void {
|
195 | 194 | this.set({
|
@@ -232,43 +231,41 @@ export class NgtsCaustics extends NgtRxStore implements OnInit {
|
232 | 231 | this.effect(
|
233 | 232 | combineLatest([
|
234 | 233 | this.sceneRef.$,
|
235 |
| - this.sceneRef.children$('both'), |
| 234 | + this.sceneRef.children$(), |
236 | 235 | this.causticsRef.$,
|
237 | 236 | this.cameraRef.$,
|
238 |
| - this.planeRef.$, |
239 |
| - this.planeRef.children$('both'), |
240 | 237 | this.normalTargetFbo.$,
|
241 | 238 | this.normalTargetBFbo.$,
|
242 | 239 | this.causticsTargetFbo.$,
|
243 | 240 | this.causticsTargetBFbo.$,
|
| 241 | + this.planeRef.$, |
| 242 | + this.planeRef.children$('both'), |
244 | 243 | ]),
|
245 | 244 | ([
|
246 | 245 | scene,
|
247 | 246 | children,
|
248 | 247 | caustics,
|
249 | 248 | camera,
|
250 |
| - plane, |
251 |
| - , |
252 | 249 | normalTarget,
|
253 | 250 | normalTargetB,
|
254 | 251 | causticsTarget,
|
255 | 252 | causticsTargetB,
|
| 253 | + plane, |
256 | 254 | ]) => {
|
257 |
| - const v = new THREE.Vector3(); |
258 |
| - const lpF = new THREE.Frustum(); |
259 |
| - const lpM = new THREE.Matrix4(); |
260 |
| - const lpP = new THREE.Plane(); |
261 |
| - |
262 |
| - const lightDir = new THREE.Vector3(); |
263 |
| - const lightDirInv = new THREE.Vector3(); |
264 |
| - const bounds = new THREE.Box3(); |
265 |
| - const focusPos = new THREE.Vector3(); |
266 |
| - |
267 |
| - let count = 0; |
268 |
| - |
269 | 255 | caustics.updateWorldMatrix(false, true);
|
270 | 256 |
|
271 | 257 | if (children.length > 1) {
|
| 258 | + const v = new THREE.Vector3(); |
| 259 | + const lpF = new THREE.Frustum(); |
| 260 | + const lpM = new THREE.Matrix4(); |
| 261 | + const lpP = new THREE.Plane(); |
| 262 | + |
| 263 | + const lightDir = new THREE.Vector3(); |
| 264 | + const lightDirInv = new THREE.Vector3(); |
| 265 | + const bounds = new THREE.Box3(); |
| 266 | + const focusPos = new THREE.Vector3(); |
| 267 | + |
| 268 | + let count = 0; |
272 | 269 | return this.store.get('internal').subscribe(({ gl }) => {
|
273 | 270 | const {
|
274 | 271 | frames,
|
@@ -399,10 +396,10 @@ export class NgtsCaustics extends NgtRxStore implements OnInit {
|
399 | 396 |
|
400 | 397 | // Render front face caustics
|
401 | 398 | causticsMaterial.ior = ior;
|
402 |
| - // @ts-ignore |
403 |
| - plane.material.lightProjMatrix = camera.projectionMatrix; |
404 |
| - // @ts-ignore |
405 |
| - plane.material.lightViewMatrix = camera.matrixWorldInverse; |
| 399 | + (plane.material as CausticsProjectionMaterialType).lightProjMatrix = |
| 400 | + camera.projectionMatrix; |
| 401 | + (plane.material as CausticsProjectionMaterialType).lightViewMatrix = |
| 402 | + camera.matrixWorldInverse; |
406 | 403 | causticsMaterial.normalTexture = normalTarget.texture;
|
407 | 404 | causticsMaterial.depthTexture = normalTarget.depthTexture;
|
408 | 405 | gl.setRenderTarget(causticsTarget);
|
|
0 commit comments