fix: Fix crystal issues

This commit is contained in:
FMS-Cat
2021-04-03 09:54:06 +09:00
parent c8f3abe286
commit cd53eb0231
4 changed files with 18 additions and 19 deletions

View File

@@ -69,11 +69,6 @@ export class Crystal extends Entity {
}
}
objectValuesMap( materials, ( material ) => {
material?.addUniform( 'size', '2f', width, height );
material?.addUniform( 'noiseOffset', '1f', noiseOffset );
} );
// haha
auto( 'Crystal/enableDepth', ( { uninit } ) => {
if ( uninit ) {
@@ -103,6 +98,9 @@ export class Crystal extends Entity {
.inverse!
.elements
);
material?.addUniform( 'size', '2f', width, height );
material?.addUniform( 'noiseOffset', '1f', noiseOffset );
} );
},
name: process.env.DEV && 'Crystal/updater',

View File

@@ -93,6 +93,7 @@ export class SceneCrystals extends Entity {
light1.transform.lookAt( new Vector3( [ 0.0, 4.0, 1.0 ] ) );
auto( 'SceneCrystals/light/amp', ( { value } ) => {
light1.active = value > 0.0;
light1.color = [ 100.0 * value, 100.0 * value, 100.0 * value ];
} );

View File

@@ -179,6 +179,19 @@ if ( process.env.DEV && module.hot ) {
} );
}
const replacerSceneCrystals = new EntityReplacer(
() => new SceneCrystals( { scenes: [ dog.root ] } ),
'SceneCrystals',
);
if ( process.env.DEV && module.hot ) {
module.hot.accept( './entities/SceneCrystals', () => {
replacerSceneCrystals.current.lights.map( ( light ) => arraySetDelete( lights, light ) );
replacerSceneCrystals.replace();
lights.push( ...replacerSceneCrystals.current.lights );
replacerSceneCrystals.current.setDefferedCameraTarget( deferredCamera.cameraTarget );
} );
}
const replacerSceneDynamic = new EntityReplacer(
() => new SceneDynamic( { scenes: [ dog.root ] } ),
'SceneDynamic',
@@ -207,19 +220,6 @@ if ( process.env.DEV && module.hot ) {
} );
}
const replacerSceneCrystals = new EntityReplacer(
() => new SceneCrystals( { scenes: [ dog.root ] } ),
'SceneCrystals',
);
if ( process.env.DEV && module.hot ) {
module.hot.accept( './entities/SceneCrystals', () => {
replacerSceneCrystals.current.lights.map( ( light ) => arraySetDelete( lights, light ) );
replacerSceneCrystals.replace();
lights.push( ...replacerSceneCrystals.current.lights );
replacerSceneCrystals.current.setDefferedCameraTarget( deferredCamera.cameraTarget );
} );
}
const replacerScenePsy = new EntityReplacer(
() => new ScenePsy( { scenes: [ dog.root ] } ),
'ScenePsy'

View File

@@ -135,7 +135,7 @@ void main() {
float shadowDepth = linearstep(
cameraNearFar.x,
cameraNearFar.y,
length( cameraPos - rayPos )
length( cameraPos - modelPos.xyz )
);
fragColor = vec4( shadowDepth, shadowDepth * shadowDepth, shadowDepth, 1.0 );
#endif