Update cloth.component.ts
This commit is contained in:
@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
|
||||
import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from '@angular/material/card';
|
||||
import {TranslatePipe} from '@ngx-translate/core';
|
||||
import {BabylonCanvas, RenderConfig, SceneEventData} from '../../../shared/rendering/canvas/babylon-canvas.component';
|
||||
import { ComputeShader, StorageBuffer, MeshBuilder, ShaderMaterial, ShaderLanguage } from '@babylonjs/core';
|
||||
import {ComputeShader, StorageBuffer, MeshBuilder, ShaderMaterial, ShaderLanguage, ArcRotateCamera} from '@babylonjs/core';
|
||||
import {CLOTH_FRAGMENT_SHADER_WGSL, CLOTH_INTEGRATE_COMPUTE_WGSL, CLOTH_SOLVE_COMPUTE_WGSL, CLOTH_VELOCITY_COMPUTE_WGSL, CLOTH_VERTEX_SHADER_WGSL} from './cloth.shader';
|
||||
|
||||
@Component({
|
||||
@@ -172,11 +172,16 @@ export class ClothComponent {
|
||||
shaderLanguage: ShaderLanguage.WGSL
|
||||
});
|
||||
|
||||
clothMaterial.backFaceCulling = false;
|
||||
clothMaterial.setStorageBuffer("positions", positionsBuffer);
|
||||
clothMesh.material = clothMaterial;
|
||||
|
||||
clothMaterial.setStorageBuffer("positions", positionsBuffer);
|
||||
clothMesh.material = clothMaterial;
|
||||
const camera = scene.activeCamera as ArcRotateCamera;
|
||||
if (camera) {
|
||||
camera.alpha = Math.PI / 4;
|
||||
camera.beta = Math.PI / 2.5;
|
||||
camera.radius = 15;
|
||||
}
|
||||
|
||||
// --- 6. RENDER LOOP ---
|
||||
scene.onBeforeRenderObservable.clear();
|
||||
@@ -194,14 +199,14 @@ export class ClothComponent {
|
||||
const dispatchXVertices = Math.ceil(numVertices / 64);
|
||||
const dispatchXConstraints = Math.ceil(numConstraints / 64);
|
||||
|
||||
csIntegrate.dispatch(dispatchXVertices, 1, 1);
|
||||
/*csIntegrate.dispatch(dispatchXVertices, 1, 1);
|
||||
|
||||
// For XPBD stability, you often run the solver multiple times (substeps)
|
||||
for (let i = 0; i < 5; i++) {
|
||||
csSolve.dispatch(dispatchXConstraints, 1, 1);
|
||||
}
|
||||
|
||||
csVelocity.dispatch(dispatchXVertices, 1, 1);
|
||||
csVelocity.dispatch(dispatchXVertices, 1, 1);*/
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user