feature: more automaton integration

This commit is contained in:
FMS-Cat
2021-03-22 20:34:38 +09:00
parent 879b9d91e2
commit afe4af247d
4 changed files with 55 additions and 26 deletions

File diff suppressed because one or more lines are too long

View File

@@ -10,6 +10,7 @@ import { Swap, Xorshift } from '@fms-cat/experimental';
import { Lambda } from '../heck/components/Lambda'; import { Lambda } from '../heck/components/Lambda';
import { CubemapRenderTarget } from '../heck/CubemapRenderTarget'; import { CubemapRenderTarget } from '../heck/CubemapRenderTarget';
import { gl } from '../globals/canvas'; import { gl } from '../globals/canvas';
import { auto } from '../globals/automaton';
const WIDTH = 1024; const WIDTH = 1024;
const HEIGHT = 512; const HEIGHT = 512;
@@ -94,6 +95,11 @@ export class EnvironmentMap {
// -- this is the output ----------------------------------------------------------------------- // -- this is the output -----------------------------------------------------------------------
this.texture = swap.o.texture; this.texture = swap.o.texture;
// -- auto -------------------------------------------------------------------------------------
auto( 'EnvironmentMap/accumulate', ( { value } ) => {
materialIntegrate.addUniform( 'accumulate', '1f', value );
} );
// -- updater ---------------------------------------------------------------------------------- // -- updater ----------------------------------------------------------------------------------
this.entity.components.push( new Lambda( { this.entity.components.push( new Lambda( {
onUpdate: () => { onUpdate: () => {

View File

@@ -15,7 +15,7 @@ import { Rings } from './entities/Rings';
import { RTInspector } from './entities/RTInspector'; import { RTInspector } from './entities/RTInspector';
import { SphereParticles } from './entities/SphereParticles'; import { SphereParticles } from './entities/SphereParticles';
import { Trails } from './entities/Trails'; import { Trails } from './entities/Trails';
import { automaton } from './globals/automaton'; import { auto, automaton } from './globals/automaton';
import { music } from './globals/music'; import { music } from './globals/music';
import { randomTexture } from './globals/randomTexture'; import { randomTexture } from './globals/randomTexture';
import { BufferRenderTarget } from './heck/BufferRenderTarget'; import { BufferRenderTarget } from './heck/BufferRenderTarget';
@@ -56,18 +56,34 @@ class EntityReplacer<T extends { entity: Entity }> {
public current?: T; public current?: T;
public creator: () => T; public creator: () => T;
public constructor( creator: () => T ) { public constructor( creator: () => T, name?: string ) {
this.creator = creator; this.creator = creator;
this.replace(); this.replace();
if ( name ) {
auto( `${ name }/active`, ( { uninit } ) => {
const entity = this.current?.entity;
if ( entity ) {
entity.active = !uninit;
entity.visible = !uninit;
}
} );
}
} }
public replace(): void { public replace(): void {
if ( process.env.DEV ) {
if ( this.current ) { if ( this.current ) {
arraySetDelete( dog.root.children, this.current.entity ); arraySetDelete( dog.root.children, this.current.entity );
} }
}
this.current = this.creator(); this.current = this.creator();
dog.root.children.push( this.current.entity ); dog.root.children.push( this.current.entity );
// not visible by default
this.current.entity.active = false;
this.current.entity.visible = false;
} }
} }
@@ -76,42 +92,48 @@ const ibllut = new IBLLUT();
dog.root.children.push( ibllut.entity ); dog.root.children.push( ibllut.entity );
// -- "objects" ------------------------------------------------------------------------------------ // -- "objects" ------------------------------------------------------------------------------------
// const replacerSphereParticles = new EntityReplacer( () => new SphereParticles() ); const replacerSphereParticles = new EntityReplacer(
// if ( process.env.DEV && module.hot ) { () => new SphereParticles(),
// module.hot.accept( './entities/SphereParticles', () => { 'SphereParticles',
// replacerSphereParticles.replace(); );
// } ); if ( process.env.DEV && module.hot ) {
// } module.hot.accept( './entities/SphereParticles', () => {
replacerSphereParticles.replace();
} );
}
// const replacerTrails = new EntityReplacer( () => new Trails() ); const replacerTrails = new EntityReplacer( () => new Trails(), 'Trails' );
// if ( process.env.DEV && module.hot ) { if ( process.env.DEV && module.hot ) {
// module.hot.accept( './entities/Trails', () => { module.hot.accept( './entities/Trails', () => {
// replacerTrails.replace(); replacerTrails.replace();
// } ); } );
// } }
const replacerRings = new EntityReplacer( () => new Rings() ); const replacerRings = new EntityReplacer( () => new Rings(), 'Rings' );
if ( process.env.DEV && module.hot ) { if ( process.env.DEV && module.hot ) {
module.hot.accept( './entities/Rings', () => { module.hot.accept( './entities/Rings', () => {
replacerRings.replace(); replacerRings.replace();
} ); } );
} }
// const replacerCube = new EntityReplacer( () => new Cube() ); const replacerCube = new EntityReplacer( () => new Cube(), 'Cube' );
// if ( process.env.DEV && module.hot ) { if ( process.env.DEV && module.hot ) {
// module.hot.accept( './entities/Cube', () => { module.hot.accept( './entities/Cube', () => {
// replacerCube.replace(); replacerCube.replace();
// } ); } );
// } }
const replacerFlickyParticles = new EntityReplacer( () => new FlickyParticles() ); const replacerFlickyParticles = new EntityReplacer(
() => new FlickyParticles(),
'FlickyParticles',
);
if ( process.env.DEV && module.hot ) { if ( process.env.DEV && module.hot ) {
module.hot.accept( './entities/FlickyParticles', () => { module.hot.accept( './entities/FlickyParticles', () => {
replacerFlickyParticles.replace(); replacerFlickyParticles.replace();
} ); } );
} }
const replacerRaymarcher = new EntityReplacer( () => new Raymarcher() ); const replacerRaymarcher = new EntityReplacer( () => new Raymarcher(), 'Raymarcher' );
if ( process.env.DEV && module.hot ) { if ( process.env.DEV && module.hot ) {
module.hot.accept( './entities/Raymarcher', () => { module.hot.accept( './entities/Raymarcher', () => {
replacerRaymarcher.replace(); replacerRaymarcher.replace();

View File

@@ -16,6 +16,7 @@ in vec2 vUv;
out vec4 fragColor; out vec4 fragColor;
uniform float accumulate;
uniform float head; uniform float head;
uniform vec2 resolution; uniform vec2 resolution;
uniform vec4 uniformSeed; uniform vec4 uniformSeed;