mirror of
https://github.com/FMS-Cat/condition.git
synced 2025-09-02 18:02:38 +02:00
refactor: Globalize so many things
This commit is contained in:
@@ -11,8 +11,8 @@ import { AO_RESOLUTION_RATIO } from '../config';
|
|||||||
import aoFrag from '../shaders/ao.frag';
|
import aoFrag from '../shaders/ao.frag';
|
||||||
import quadVert from '../shaders/quad.vert';
|
import quadVert from '../shaders/quad.vert';
|
||||||
import shadingFrag from '../shaders/shading.frag';
|
import shadingFrag from '../shaders/shading.frag';
|
||||||
import { gl } from '../heck/canvas';
|
import { gl } from '../globals/canvas';
|
||||||
import { randomTexture } from '../utils/RandomTexture';
|
import { randomTexture } from '../globals/randomTexture';
|
||||||
|
|
||||||
export interface CameraEntityOptions {
|
export interface CameraEntityOptions {
|
||||||
root: Entity;
|
root: Entity;
|
||||||
|
@@ -9,8 +9,8 @@ import flickyParticleComputeFrag from '../shaders/flicky-particles-compute.frag'
|
|||||||
import flickyParticleRenderFrag from '../shaders/flicky-particles-render.frag';
|
import flickyParticleRenderFrag from '../shaders/flicky-particles-render.frag';
|
||||||
import flickyParticleRenderVert from '../shaders/flicky-particles-render.vert';
|
import flickyParticleRenderVert from '../shaders/flicky-particles-render.vert';
|
||||||
import { TRIANGLE_STRIP_QUAD } from '@fms-cat/experimental';
|
import { TRIANGLE_STRIP_QUAD } from '@fms-cat/experimental';
|
||||||
import { gl, glCat } from '../heck/canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { randomTexture, randomTextureStatic } from '../utils/RandomTexture';
|
import { randomTexture, randomTextureStatic } from '../globals/randomTexture';
|
||||||
|
|
||||||
export interface FlickyParticlesOptions {
|
export interface FlickyParticlesOptions {
|
||||||
particlesSqrt: number;
|
particlesSqrt: number;
|
||||||
|
@@ -6,7 +6,7 @@ import { Material } from '../heck/Material';
|
|||||||
import { Mesh } from '../heck/components/Mesh';
|
import { Mesh } from '../heck/components/Mesh';
|
||||||
import { Quad } from '../heck/components/Quad';
|
import { Quad } from '../heck/components/Quad';
|
||||||
import { Swap } from '@fms-cat/experimental';
|
import { Swap } from '@fms-cat/experimental';
|
||||||
import { gl } from '../heck/canvas';
|
import { gl } from '../globals/canvas';
|
||||||
|
|
||||||
export interface GPUParticlesOptions {
|
export interface GPUParticlesOptions {
|
||||||
materialCompute: Material;
|
materialCompute: Material;
|
||||||
|
@@ -4,15 +4,14 @@ import { Quad } from '../heck/components/Quad';
|
|||||||
import { RenderTarget } from '../heck/RenderTarget';
|
import { RenderTarget } from '../heck/RenderTarget';
|
||||||
import quadVert from '../shaders/quad.vert';
|
import quadVert from '../shaders/quad.vert';
|
||||||
import glitchFrag from '../shaders/glitch.frag';
|
import glitchFrag from '../shaders/glitch.frag';
|
||||||
import { Automaton } from '@fms-cat/automaton';
|
|
||||||
import returnFrag from '../shaders/return.frag';
|
import returnFrag from '../shaders/return.frag';
|
||||||
import { BufferRenderTarget } from '../heck/BufferRenderTarget';
|
import { BufferRenderTarget } from '../heck/BufferRenderTarget';
|
||||||
import { Blit } from '../heck/components/Blit';
|
import { Blit } from '../heck/components/Blit';
|
||||||
|
import { auto } from '../globals/automaton';
|
||||||
|
|
||||||
export interface GlitchOptions {
|
export interface GlitchOptions {
|
||||||
input: BufferRenderTarget;
|
input: BufferRenderTarget;
|
||||||
target: RenderTarget;
|
target: RenderTarget;
|
||||||
automaton: Automaton;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Glitch {
|
export class Glitch {
|
||||||
@@ -67,7 +66,7 @@ export class Glitch {
|
|||||||
entityMain.components.push( quad );
|
entityMain.components.push( quad );
|
||||||
|
|
||||||
// -- update uniform ---------------------------------------------------------------------------
|
// -- update uniform ---------------------------------------------------------------------------
|
||||||
options.automaton.auto( 'Glitch/amp', ( { value } ) => {
|
auto( 'Glitch/amp', ( { value } ) => {
|
||||||
this.material.addUniform( 'amp', '1f', value );
|
this.material.addUniform( 'amp', '1f', value );
|
||||||
|
|
||||||
entityMain.active = 0.0 < value;
|
entityMain.active = 0.0 < value;
|
||||||
|
@@ -10,11 +10,11 @@ import { BufferRenderTarget } from '../heck/BufferRenderTarget';
|
|||||||
import { Swap } from '@fms-cat/experimental';
|
import { Swap } from '@fms-cat/experimental';
|
||||||
import { Automaton } from '@fms-cat/automaton';
|
import { Automaton } from '@fms-cat/automaton';
|
||||||
import { Blit } from '../heck/components/Blit';
|
import { Blit } from '../heck/components/Blit';
|
||||||
|
import { auto } from '../globals/automaton';
|
||||||
|
|
||||||
export interface PixelSorterOptions {
|
export interface PixelSorterOptions {
|
||||||
input: BufferRenderTarget;
|
input: BufferRenderTarget;
|
||||||
target: RenderTarget;
|
target: RenderTarget;
|
||||||
automaton: Automaton;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PixelSorter {
|
export class PixelSorter {
|
||||||
@@ -142,7 +142,7 @@ export class PixelSorter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- update uniform ---------------------------------------------------------------------------
|
// -- update uniform ---------------------------------------------------------------------------
|
||||||
options.automaton.auto( 'PixelSorter/amp', ( { value } ) => {
|
auto( 'PixelSorter/amp', ( { value } ) => {
|
||||||
indexMaterials.map( ( material ) => {
|
indexMaterials.map( ( material ) => {
|
||||||
material.addUniform( 'threshold', '1f', value );
|
material.addUniform( 'threshold', '1f', value );
|
||||||
} );
|
} );
|
||||||
|
@@ -2,7 +2,7 @@ import { Entity } from '../heck/Entity';
|
|||||||
import { RenderTarget } from '../heck/RenderTarget';
|
import { RenderTarget } from '../heck/RenderTarget';
|
||||||
import { BufferRenderTarget } from '../heck/BufferRenderTarget';
|
import { BufferRenderTarget } from '../heck/BufferRenderTarget';
|
||||||
import { RTINSPECTOR_CAPTURE_INDEX, RTINSPECTOR_CAPTURE_NAME, RTINSPECTOR_MULTIPLE } from '../config-hot';
|
import { RTINSPECTOR_CAPTURE_INDEX, RTINSPECTOR_CAPTURE_NAME, RTINSPECTOR_MULTIPLE } from '../config-hot';
|
||||||
import { gl } from '../heck/canvas';
|
import { gl } from '../globals/canvas';
|
||||||
import { Blit } from '../heck/components/Blit';
|
import { Blit } from '../heck/components/Blit';
|
||||||
|
|
||||||
export interface RTInspectorOptions {
|
export interface RTInspectorOptions {
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
import { GLCatTexture } from '@fms-cat/glcat-ts';
|
import { GLCatTexture } from '@fms-cat/glcat-ts';
|
||||||
import { Mesh, MeshCull } from '../heck/components/Mesh';
|
import { Mesh, MeshCull } from '../heck/components/Mesh';
|
||||||
import { TRIANGLE_STRIP_QUAD, Vector3 } from '@fms-cat/experimental';
|
import { TRIANGLE_STRIP_QUAD, Vector3 } from '@fms-cat/experimental';
|
||||||
import { gl, glCat } from '../heck/canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { Entity } from '../heck/Entity';
|
import { Entity } from '../heck/Entity';
|
||||||
import { Geometry } from '../heck/Geometry';
|
import { Geometry } from '../heck/Geometry';
|
||||||
import { Material } from '../heck/Material';
|
import { Material } from '../heck/Material';
|
||||||
import quadVert from '../shaders/quad.vert';
|
import quadVert from '../shaders/quad.vert';
|
||||||
import raymarcherFrag from '../shaders/raymarcher.frag';
|
import raymarcherFrag from '../shaders/raymarcher.frag';
|
||||||
import { Lambda } from '../heck/components/Lambda';
|
import { Lambda } from '../heck/components/Lambda';
|
||||||
import { randomTexture, randomTextureStatic } from '../utils/RandomTexture';
|
import { randomTexture, randomTextureStatic } from '../globals/randomTexture';
|
||||||
|
|
||||||
export class Raymarcher {
|
export class Raymarcher {
|
||||||
private __mesh: Mesh;
|
private __mesh: Mesh;
|
||||||
|
@@ -7,7 +7,7 @@ import { InstancedGeometry } from '../heck/InstancedGeometry';
|
|||||||
import { Material } from '../heck/Material';
|
import { Material } from '../heck/Material';
|
||||||
import ringsVert from '../shaders/rings.vert';
|
import ringsVert from '../shaders/rings.vert';
|
||||||
import ringsFrag from '../shaders/rings.frag';
|
import ringsFrag from '../shaders/rings.frag';
|
||||||
import { gl, glCat } from '../heck/canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
|
|
||||||
const PRIMCOUNT = 32;
|
const PRIMCOUNT = 32;
|
||||||
|
|
||||||
|
@@ -8,12 +8,11 @@ import quadVert from '../shaders/quad.vert';
|
|||||||
import sphereParticleComputeFrag from '../shaders/sphere-particles-compute.frag';
|
import sphereParticleComputeFrag from '../shaders/sphere-particles-compute.frag';
|
||||||
import sphereParticleRenderFrag from '../shaders/sphere-particles-render.frag';
|
import sphereParticleRenderFrag from '../shaders/sphere-particles-render.frag';
|
||||||
import sphereParticleRenderVert from '../shaders/sphere-particles-render.vert';
|
import sphereParticleRenderVert from '../shaders/sphere-particles-render.vert';
|
||||||
import { gl, glCat } from '../heck/canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { randomTexture, randomTextureStatic } from '../utils/RandomTexture';
|
import { randomTexture, randomTextureStatic } from '../globals/randomTexture';
|
||||||
|
|
||||||
export interface SphereParticlesOptions {
|
const PARTICLES_SQRT = 256;
|
||||||
particlesSqrt: number;
|
const PARTICLES = PARTICLES_SQRT * PARTICLES_SQRT;
|
||||||
}
|
|
||||||
|
|
||||||
export class SphereParticles {
|
export class SphereParticles {
|
||||||
public get entity(): Entity {
|
public get entity(): Entity {
|
||||||
@@ -30,25 +29,22 @@ export class SphereParticles {
|
|||||||
return this.__gpuParticles.materialRender;
|
return this.__gpuParticles.materialRender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public constructor( options: SphereParticlesOptions ) {
|
public constructor() {
|
||||||
this.__gpuParticles = new GPUParticles( {
|
this.__gpuParticles = new GPUParticles( {
|
||||||
materialCompute: this.__createMaterialCompute( options ),
|
materialCompute: this.__createMaterialCompute(),
|
||||||
geometryRender: this.__createGeometryRender( options ),
|
geometryRender: this.__createGeometryRender(),
|
||||||
materialRender: this.__createMaterialRender( options ),
|
materialRender: this.__createMaterialRender(),
|
||||||
computeWidth: options.particlesSqrt,
|
computeWidth: PARTICLES_SQRT,
|
||||||
computeHeight: options.particlesSqrt,
|
computeHeight: PARTICLES_SQRT,
|
||||||
computeNumBuffers: 2,
|
computeNumBuffers: 2,
|
||||||
namePrefix: process.env.DEV && 'SphereParticles',
|
namePrefix: process.env.DEV && 'SphereParticles',
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
private __createMaterialCompute( options: SphereParticlesOptions ): Material {
|
private __createMaterialCompute(): Material {
|
||||||
const { particlesSqrt } = options;
|
|
||||||
const particles = particlesSqrt * particlesSqrt;
|
|
||||||
|
|
||||||
const material = new Material( quadVert, sphereParticleComputeFrag );
|
const material = new Material( quadVert, sphereParticleComputeFrag );
|
||||||
material.addUniform( 'particlesSqrt', '1f', particlesSqrt );
|
material.addUniform( 'particlesSqrt', '1f', PARTICLES_SQRT );
|
||||||
material.addUniform( 'particles', '1f', particles );
|
material.addUniform( 'particles', '1f', PARTICLES );
|
||||||
material.addUniformTexture( 'samplerRandom', randomTexture.texture );
|
material.addUniformTexture( 'samplerRandom', randomTexture.texture );
|
||||||
|
|
||||||
if ( process.env.DEV ) {
|
if ( process.env.DEV ) {
|
||||||
@@ -62,10 +58,7 @@ export class SphereParticles {
|
|||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
private __createGeometryRender( options: SphereParticlesOptions ): Geometry {
|
private __createGeometryRender(): Geometry {
|
||||||
const { particlesSqrt } = options;
|
|
||||||
const particles = particlesSqrt * particlesSqrt;
|
|
||||||
|
|
||||||
const octahedron = genOctahedron( { radius: 1.0, div: 1 } );
|
const octahedron = genOctahedron( { radius: 1.0, div: 1 } );
|
||||||
|
|
||||||
const geometry = new InstancedGeometry();
|
const geometry = new InstancedGeometry();
|
||||||
@@ -76,12 +69,12 @@ export class SphereParticles {
|
|||||||
|
|
||||||
const bufferComputeUV = glCat.createBuffer();
|
const bufferComputeUV = glCat.createBuffer();
|
||||||
bufferComputeUV.setVertexbuffer( ( () => {
|
bufferComputeUV.setVertexbuffer( ( () => {
|
||||||
const ret = new Float32Array( particles * 2 );
|
const ret = new Float32Array( PARTICLES * 2 );
|
||||||
for ( let iy = 0; iy < particlesSqrt; iy ++ ) {
|
for ( let iy = 0; iy < PARTICLES_SQRT; iy ++ ) {
|
||||||
for ( let ix = 0; ix < particlesSqrt; ix ++ ) {
|
for ( let ix = 0; ix < PARTICLES_SQRT; ix ++ ) {
|
||||||
const i = ix + iy * particlesSqrt;
|
const i = ix + iy * PARTICLES_SQRT;
|
||||||
const s = ( ix + 0.5 ) / particlesSqrt;
|
const s = ( ix + 0.5 ) / PARTICLES_SQRT;
|
||||||
const t = ( iy + 0.5 ) / particlesSqrt;
|
const t = ( iy + 0.5 ) / PARTICLES_SQRT;
|
||||||
ret[ i * 2 + 0 ] = s;
|
ret[ i * 2 + 0 ] = s;
|
||||||
ret[ i * 2 + 1 ] = t;
|
ret[ i * 2 + 1 ] = t;
|
||||||
}
|
}
|
||||||
@@ -98,12 +91,12 @@ export class SphereParticles {
|
|||||||
|
|
||||||
geometry.count = octahedron.count;
|
geometry.count = octahedron.count;
|
||||||
geometry.mode = octahedron.mode;
|
geometry.mode = octahedron.mode;
|
||||||
geometry.primcount = options.particlesSqrt * options.particlesSqrt;
|
geometry.primcount = PARTICLES_SQRT * PARTICLES_SQRT;
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
private __createMaterialRender( options: SphereParticlesOptions ): Material {
|
private __createMaterialRender(): Material {
|
||||||
const material = new Material(
|
const material = new Material(
|
||||||
sphereParticleRenderVert,
|
sphereParticleRenderVert,
|
||||||
sphereParticleRenderFrag,
|
sphereParticleRenderFrag,
|
||||||
|
@@ -7,13 +7,11 @@ import quadVert from '../shaders/quad.vert';
|
|||||||
import trailsComputeFrag from '../shaders/trails-compute.frag';
|
import trailsComputeFrag from '../shaders/trails-compute.frag';
|
||||||
import trailsRenderFrag from '../shaders/trails-render.frag';
|
import trailsRenderFrag from '../shaders/trails-render.frag';
|
||||||
import trailsRenderVert from '../shaders/trails-render.vert';
|
import trailsRenderVert from '../shaders/trails-render.vert';
|
||||||
import { gl, glCat } from '../heck/canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { randomTexture, randomTextureStatic } from '../utils/RandomTexture';
|
import { randomTexture, randomTextureStatic } from '../globals/randomTexture';
|
||||||
|
|
||||||
export interface TrailsOptions {
|
const TRAILS = 4096;
|
||||||
trails: number;
|
const TRAIL_LENGTH = 64;
|
||||||
trailLength: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Trails {
|
export class Trails {
|
||||||
public get entity(): Entity {
|
public get entity(): Entity {
|
||||||
@@ -30,22 +28,22 @@ export class Trails {
|
|||||||
return this.__gpuParticles.materialRender;
|
return this.__gpuParticles.materialRender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public constructor( options: TrailsOptions ) {
|
public constructor() {
|
||||||
this.__gpuParticles = new GPUParticles( {
|
this.__gpuParticles = new GPUParticles( {
|
||||||
materialCompute: this.__createMaterialCompute( options ),
|
materialCompute: this.__createMaterialCompute(),
|
||||||
geometryRender: this.__createGeometryRender( options ),
|
geometryRender: this.__createGeometryRender(),
|
||||||
materialRender: this.__createMaterialRender( options ),
|
materialRender: this.__createMaterialRender(),
|
||||||
computeWidth: options.trailLength,
|
computeWidth: TRAIL_LENGTH,
|
||||||
computeHeight: options.trails,
|
computeHeight: TRAILS,
|
||||||
computeNumBuffers: 2,
|
computeNumBuffers: 2,
|
||||||
namePrefix: process.env.DEV && 'Trails',
|
namePrefix: process.env.DEV && 'Trails',
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
private __createMaterialCompute( options: TrailsOptions ): Material {
|
private __createMaterialCompute(): Material {
|
||||||
const material = new Material( quadVert, trailsComputeFrag );
|
const material = new Material( quadVert, trailsComputeFrag );
|
||||||
material.addUniform( 'trails', '1f', options.trails );
|
material.addUniform( 'trails', '1f', TRAILS );
|
||||||
material.addUniform( 'trailLength', '1f', options.trailLength );
|
material.addUniform( 'trailLength', '1f', TRAIL_LENGTH );
|
||||||
material.addUniformTexture( 'samplerRandom', randomTexture.texture );
|
material.addUniformTexture( 'samplerRandom', randomTexture.texture );
|
||||||
|
|
||||||
if ( process.env.DEV ) {
|
if ( process.env.DEV ) {
|
||||||
@@ -59,14 +57,14 @@ export class Trails {
|
|||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
private __createGeometryRender( options: TrailsOptions ): Geometry {
|
private __createGeometryRender(): Geometry {
|
||||||
const geometry = new InstancedGeometry();
|
const geometry = new InstancedGeometry();
|
||||||
|
|
||||||
const bufferComputeU = glCat.createBuffer();
|
const bufferComputeU = glCat.createBuffer();
|
||||||
bufferComputeU.setVertexbuffer( ( () => {
|
bufferComputeU.setVertexbuffer( ( () => {
|
||||||
const ret = new Float32Array( options.trailLength * 3 );
|
const ret = new Float32Array( TRAIL_LENGTH * 3 );
|
||||||
for ( let i = 0; i < options.trailLength; i ++ ) {
|
for ( let i = 0; i < TRAIL_LENGTH; i ++ ) {
|
||||||
const u = ( 0.5 + i ) / options.trailLength;
|
const u = ( 0.5 + i ) / TRAIL_LENGTH;
|
||||||
ret[ i * 3 + 0 ] = u;
|
ret[ i * 3 + 0 ] = u;
|
||||||
ret[ i * 3 + 1 ] = u;
|
ret[ i * 3 + 1 ] = u;
|
||||||
ret[ i * 3 + 2 ] = u;
|
ret[ i * 3 + 2 ] = u;
|
||||||
@@ -82,9 +80,9 @@ export class Trails {
|
|||||||
|
|
||||||
const bufferComputeV = glCat.createBuffer();
|
const bufferComputeV = glCat.createBuffer();
|
||||||
bufferComputeV.setVertexbuffer( ( () => {
|
bufferComputeV.setVertexbuffer( ( () => {
|
||||||
const ret = new Float32Array( options.trails );
|
const ret = new Float32Array( TRAILS );
|
||||||
for ( let i = 0; i < options.trails; i ++ ) {
|
for ( let i = 0; i < TRAILS; i ++ ) {
|
||||||
ret[ i ] = ( i + 0.5 ) / options.trails;
|
ret[ i ] = ( i + 0.5 ) / TRAILS;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
} )() );
|
} )() );
|
||||||
@@ -98,8 +96,8 @@ export class Trails {
|
|||||||
|
|
||||||
const bufferTriIndex = glCat.createBuffer();
|
const bufferTriIndex = glCat.createBuffer();
|
||||||
bufferTriIndex.setVertexbuffer( ( () => {
|
bufferTriIndex.setVertexbuffer( ( () => {
|
||||||
const ret = new Float32Array( 3 * options.trailLength );
|
const ret = new Float32Array( 3 * TRAIL_LENGTH );
|
||||||
for ( let i = 0; i < options.trailLength; i ++ ) {
|
for ( let i = 0; i < TRAIL_LENGTH; i ++ ) {
|
||||||
ret[ i * 3 + 0 ] = 0;
|
ret[ i * 3 + 0 ] = 0;
|
||||||
ret[ i * 3 + 1 ] = 1;
|
ret[ i * 3 + 1 ] = 1;
|
||||||
ret[ i * 3 + 2 ] = 2;
|
ret[ i * 3 + 2 ] = 2;
|
||||||
@@ -115,8 +113,8 @@ export class Trails {
|
|||||||
|
|
||||||
const indexBuffer = glCat.createBuffer();
|
const indexBuffer = glCat.createBuffer();
|
||||||
indexBuffer.setIndexbuffer( ( () => {
|
indexBuffer.setIndexbuffer( ( () => {
|
||||||
const ret = new Uint16Array( ( options.trailLength - 1 ) * 18 );
|
const ret = new Uint16Array( ( TRAIL_LENGTH - 1 ) * 18 );
|
||||||
for ( let i = 0; i < options.trailLength - 1; i ++ ) {
|
for ( let i = 0; i < TRAIL_LENGTH - 1; i ++ ) {
|
||||||
for ( let j = 0; j < 3; j ++ ) {
|
for ( let j = 0; j < 3; j ++ ) {
|
||||||
const jn = ( j + 1 ) % 3;
|
const jn = ( j + 1 ) % 3;
|
||||||
ret[ i * 18 + j * 6 + 0 ] = i * 3 + j;
|
ret[ i * 18 + j * 6 + 0 ] = i * 3 + j;
|
||||||
@@ -135,14 +133,14 @@ export class Trails {
|
|||||||
type: gl.UNSIGNED_SHORT
|
type: gl.UNSIGNED_SHORT
|
||||||
} );
|
} );
|
||||||
|
|
||||||
geometry.count = ( options.trailLength - 1 ) * 18;
|
geometry.count = ( TRAIL_LENGTH - 1 ) * 18;
|
||||||
geometry.primcount = options.trails;
|
geometry.primcount = TRAILS;
|
||||||
geometry.mode = gl.TRIANGLES;
|
geometry.mode = gl.TRIANGLES;
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
private __createMaterialRender( options: TrailsOptions ): Material {
|
private __createMaterialRender(): Material {
|
||||||
const material = new Material(
|
const material = new Material(
|
||||||
trailsRenderVert,
|
trailsRenderVert,
|
||||||
trailsRenderFrag,
|
trailsRenderFrag,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { gl, glCat } from '../heck/canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { GeometryAttribute, GeometryIndex } from '../heck/Geometry';
|
import { GeometryAttribute, GeometryIndex } from '../heck/Geometry';
|
||||||
|
|
||||||
interface ResultGenCube {
|
interface ResultGenCube {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { gl, glCat } from '../heck/canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { GeometryAttribute, GeometryIndex } from '../heck/Geometry';
|
import { GeometryAttribute, GeometryIndex } from '../heck/Geometry';
|
||||||
|
|
||||||
interface ResultGenOctahedron {
|
interface ResultGenOctahedron {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { gl, glCat } from '../heck/canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { GeometryAttribute, GeometryIndex } from '../heck/Geometry';
|
import { GeometryAttribute, GeometryIndex } from '../heck/Geometry';
|
||||||
|
|
||||||
interface ResultGenTorus {
|
interface ResultGenTorus {
|
||||||
|
47
src/globals/automaton.ts
Normal file
47
src/globals/automaton.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { Automaton } from '@fms-cat/automaton';
|
||||||
|
import { AutomatonWithGUI } from '@fms-cat/automaton-with-gui';
|
||||||
|
import automatonData from '../automaton.json';
|
||||||
|
import * as automatonFxs from '../automaton-fxs/automatonFxs';
|
||||||
|
import { music } from './music';
|
||||||
|
import { getDivAutomaton } from './dom';
|
||||||
|
|
||||||
|
export const automaton = ( () => {
|
||||||
|
if ( process.env.DEV ) {
|
||||||
|
// this cast smells so bad
|
||||||
|
// https://github.com/FMS-Cat/automaton/issues/121
|
||||||
|
const automatonWithGUI = new AutomatonWithGUI(
|
||||||
|
automatonData,
|
||||||
|
{
|
||||||
|
gui: getDivAutomaton(),
|
||||||
|
isPlaying: true,
|
||||||
|
fxDefinitions: automatonFxs,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
automatonWithGUI.on( 'play', () => { music.isPlaying = true; } );
|
||||||
|
automatonWithGUI.on( 'pause', () => { music.isPlaying = false; } );
|
||||||
|
automatonWithGUI.on( 'seek', ( { time } ) => {
|
||||||
|
music.time = Math.max( 0.0, time );
|
||||||
|
automatonWithGUI.reset();
|
||||||
|
} );
|
||||||
|
|
||||||
|
if ( module.hot ) {
|
||||||
|
module.hot.accept( '../automaton.json', () => {
|
||||||
|
// we probably don't need this feature for now...
|
||||||
|
// See: https://github.com/FMS-Cat/automaton/issues/120
|
||||||
|
// automatonWithGUI.deserialize( automatonData );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
return automatonWithGUI;
|
||||||
|
} else {
|
||||||
|
return new Automaton(
|
||||||
|
automatonData,
|
||||||
|
{
|
||||||
|
fxDefinitions: automatonFxs
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} )();
|
||||||
|
|
||||||
|
export const auto = automaton.auto;
|
92
src/globals/dom.ts
Normal file
92
src/globals/dom.ts
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
function getElement<T extends HTMLElement>(
|
||||||
|
id: string,
|
||||||
|
tagName: string,
|
||||||
|
style: { [ key: string ]: string },
|
||||||
|
hook?: ( el: T ) => void,
|
||||||
|
): T {
|
||||||
|
let el = document.getElementById( id ) as T;
|
||||||
|
if ( el ) {
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
el = document.createElement( tagName ) as T;
|
||||||
|
el.id = id;
|
||||||
|
|
||||||
|
document.body.appendChild( el );
|
||||||
|
|
||||||
|
Object.assign( el.style, style );
|
||||||
|
|
||||||
|
hook?.( el );
|
||||||
|
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCheckboxActive(): HTMLInputElement {
|
||||||
|
return getElement<HTMLInputElement>(
|
||||||
|
'checkboxActive',
|
||||||
|
'input',
|
||||||
|
{
|
||||||
|
position: 'fixed',
|
||||||
|
left: '8px',
|
||||||
|
bottom: '248px',
|
||||||
|
},
|
||||||
|
( el ) => {
|
||||||
|
el.type = 'checkbox';
|
||||||
|
el.checked = true;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDivAutomaton(): HTMLDivElement {
|
||||||
|
return getElement<HTMLDivElement>(
|
||||||
|
'divAutomaton',
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
position: 'fixed',
|
||||||
|
width: '100%',
|
||||||
|
height: '240px',
|
||||||
|
right: '0',
|
||||||
|
bottom: '0',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDivComponentsUpdate(): HTMLDivElement {
|
||||||
|
return getElement<HTMLDivElement>(
|
||||||
|
'divComponentsUpdate',
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
whiteSpace: 'pre',
|
||||||
|
color: '#ffffff',
|
||||||
|
font: '500 10px Wt-Position-Mono',
|
||||||
|
position: 'fixed',
|
||||||
|
padding: '0',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
width: '240px',
|
||||||
|
height: 'calc( ( 100% - 240px ) * 0.5 )',
|
||||||
|
right: '0',
|
||||||
|
top: '0',
|
||||||
|
overflowY: 'scroll',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDivComponentsDraw(): HTMLDivElement {
|
||||||
|
return getElement<HTMLDivElement>(
|
||||||
|
'divComponentsDraw',
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
whiteSpace: 'pre',
|
||||||
|
color: '#ffffff',
|
||||||
|
font: '500 10px Wt-Position-Mono',
|
||||||
|
position: 'fixed',
|
||||||
|
padding: '0',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
width: '240px',
|
||||||
|
height: 'calc( ( 100% - 240px ) * 0.5 )',
|
||||||
|
right: '0',
|
||||||
|
top: 'calc( ( 100% - 240px ) * 0.5 )',
|
||||||
|
overflowY: 'scroll',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
5
src/globals/music.ts
Normal file
5
src/globals/music.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { Music } from '../Music';
|
||||||
|
import { glCat } from './canvas';
|
||||||
|
|
||||||
|
export const audio = new AudioContext();
|
||||||
|
export const music = new Music( glCat, audio );
|
17
src/globals/randomTexture.ts
Normal file
17
src/globals/randomTexture.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { glCat } from './canvas';
|
||||||
|
import { RANDOM_RESOLUTION, STATIC_RANDOM_RESOLUTION } from '../config';
|
||||||
|
import { RandomTexture } from '../utils/RandomTexture';
|
||||||
|
|
||||||
|
export const randomTexture = new RandomTexture(
|
||||||
|
glCat,
|
||||||
|
RANDOM_RESOLUTION[ 0 ],
|
||||||
|
RANDOM_RESOLUTION[ 1 ]
|
||||||
|
);
|
||||||
|
randomTexture.update();
|
||||||
|
|
||||||
|
export const randomTextureStatic = new RandomTexture(
|
||||||
|
glCat,
|
||||||
|
STATIC_RANDOM_RESOLUTION[ 0 ],
|
||||||
|
STATIC_RANDOM_RESOLUTION[ 1 ]
|
||||||
|
);
|
||||||
|
randomTextureStatic.update();
|
@@ -1,5 +1,5 @@
|
|||||||
import { GLCatFramebuffer, GLCatTexture } from '@fms-cat/glcat-ts';
|
import { GLCatFramebuffer, GLCatTexture } from '@fms-cat/glcat-ts';
|
||||||
import { gl, glCat } from './canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { RenderTarget } from './RenderTarget';
|
import { RenderTarget } from './RenderTarget';
|
||||||
|
|
||||||
export interface BufferRenderTargetOptions {
|
export interface BufferRenderTargetOptions {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { canvas, gl, glCat } from './canvas';
|
import { canvas, gl, glCat } from '../globals/canvas';
|
||||||
import { RenderTarget } from './RenderTarget';
|
import { RenderTarget } from './RenderTarget';
|
||||||
|
|
||||||
export class CanvasRenderTarget extends RenderTarget {
|
export class CanvasRenderTarget extends RenderTarget {
|
||||||
|
@@ -1,32 +1,28 @@
|
|||||||
import { Entity } from './Entity';
|
import { Entity } from './Entity';
|
||||||
import { Transform } from './Transform';
|
import { Transform } from './Transform';
|
||||||
import { Music } from '../Music';
|
|
||||||
import { Component } from './components/Component';
|
import { Component } from './components/Component';
|
||||||
|
import { music } from '../globals/music';
|
||||||
let ha = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* And what a WONDERFUL Dog they are!!
|
* And what a WONDERFUL Dog they are!!
|
||||||
*/
|
*/
|
||||||
export class Dog {
|
export class Dog {
|
||||||
public root: Entity;
|
public root: Entity;
|
||||||
public music: Music;
|
|
||||||
public active: boolean;
|
public active: boolean;
|
||||||
|
|
||||||
private __frameCount: number = 0;
|
private __frameCount: number = 0;
|
||||||
|
|
||||||
public constructor( music: Music ) {
|
public constructor() {
|
||||||
this.root = new Entity();
|
this.root = new Entity();
|
||||||
this.music = music;
|
|
||||||
this.active = true;
|
this.active = true;
|
||||||
|
|
||||||
const update = (): void => {
|
const update = (): void => {
|
||||||
if ( this.active ) {
|
if ( this.active ) {
|
||||||
this.music.update();
|
music.update();
|
||||||
this.root.update( {
|
this.root.update( {
|
||||||
frameCount: this.__frameCount ++,
|
frameCount: this.__frameCount ++,
|
||||||
time: this.music.time,
|
time: music.time,
|
||||||
deltaTime: this.music.deltaTime,
|
deltaTime: music.deltaTime,
|
||||||
globalTransform: new Transform(),
|
globalTransform: new Transform(),
|
||||||
parent: null
|
parent: null
|
||||||
} );
|
} );
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { Pool } from '../utils/Pool';
|
import { Pool } from '../utils/Pool';
|
||||||
import { gl, glCat } from './canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
|
|
||||||
export class GPUTimer {
|
export class GPUTimer {
|
||||||
public queries: Pool<WebGLQuery>;
|
public queries: Pool<WebGLQuery>;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { GLCatBuffer, GLCatTransformFeedback } from '@fms-cat/glcat-ts';
|
import { GLCatBuffer, GLCatTransformFeedback } from '@fms-cat/glcat-ts';
|
||||||
import { gl, glCat } from './canvas';
|
import { gl, glCat } from '../globals/canvas';
|
||||||
import { Material } from './Material';
|
import { Material } from './Material';
|
||||||
|
|
||||||
export interface GeometryAttribute {
|
export interface GeometryAttribute {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { gl } from './canvas';
|
import { gl } from '../globals/canvas';
|
||||||
import { Geometry } from './Geometry';
|
import { Geometry } from './Geometry';
|
||||||
|
|
||||||
export class InstancedGeometry extends Geometry {
|
export class InstancedGeometry extends Geometry {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { GLCatProgram, GLCatProgramLinkOptions, GLCatProgramUniformType, GLCatTexture } from '@fms-cat/glcat-ts';
|
import { GLCatProgram, GLCatProgramLinkOptions, GLCatProgramUniformType, GLCatTexture } from '@fms-cat/glcat-ts';
|
||||||
import { gl } from './canvas';
|
import { gl } from '../globals/canvas';
|
||||||
import { SHADERPOOL } from './ShaderPool';
|
import { SHADERPOOL } from './ShaderPool';
|
||||||
|
|
||||||
export class Material {
|
export class Material {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { GLCatProgram, GLCatProgramLinkOptions } from '@fms-cat/glcat-ts';
|
import { GLCatProgram, GLCatProgramLinkOptions } from '@fms-cat/glcat-ts';
|
||||||
import { glCat } from './canvas';
|
import { glCat } from '../globals/canvas';
|
||||||
import { Material } from './Material';
|
import { Material } from './Material';
|
||||||
|
|
||||||
export class ShaderPool<TUser> {
|
export class ShaderPool<TUser> {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { Component, ComponentOptions, ComponentUpdateEvent } from './Component';
|
import { Component, ComponentOptions, ComponentUpdateEvent } from './Component';
|
||||||
import { RenderTarget } from '../RenderTarget';
|
import { RenderTarget } from '../RenderTarget';
|
||||||
import { gl } from '../canvas';
|
import { gl } from '../../globals/canvas';
|
||||||
import { BufferRenderTarget } from '../BufferRenderTarget';
|
import { BufferRenderTarget } from '../BufferRenderTarget';
|
||||||
|
|
||||||
export interface BlitOptions extends ComponentOptions {
|
export interface BlitOptions extends ComponentOptions {
|
||||||
|
@@ -3,7 +3,7 @@ import { Entity } from '../Entity';
|
|||||||
import { Matrix4 } from '@fms-cat/experimental';
|
import { Matrix4 } from '@fms-cat/experimental';
|
||||||
import { RenderTarget } from '../RenderTarget';
|
import { RenderTarget } from '../RenderTarget';
|
||||||
import { Transform } from '../Transform';
|
import { Transform } from '../Transform';
|
||||||
import { glCat } from '../canvas';
|
import { glCat } from '../../globals/canvas';
|
||||||
|
|
||||||
export interface CameraOptions extends ComponentOptions {
|
export interface CameraOptions extends ComponentOptions {
|
||||||
renderTarget?: RenderTarget;
|
renderTarget?: RenderTarget;
|
||||||
|
@@ -5,6 +5,7 @@ import { RenderTarget } from '../RenderTarget';
|
|||||||
import { Transform } from '../Transform';
|
import { Transform } from '../Transform';
|
||||||
import { COMPONENT_DRAW_BREAKPOINT, COMPONENT_UPDATE_BREAKPOINT } from '../../config-hot';
|
import { COMPONENT_DRAW_BREAKPOINT, COMPONENT_UPDATE_BREAKPOINT } from '../../config-hot';
|
||||||
import { GPUTimer } from '../GPUTimer';
|
import { GPUTimer } from '../GPUTimer';
|
||||||
|
import { getDivComponentsDraw, getDivComponentsUpdate } from '../../globals/dom';
|
||||||
|
|
||||||
export interface ComponentUpdateEvent {
|
export interface ComponentUpdateEvent {
|
||||||
frameCount: number;
|
frameCount: number;
|
||||||
@@ -42,7 +43,9 @@ export class Component {
|
|||||||
|
|
||||||
public static resetUpdateBreakpoint(): void {
|
public static resetUpdateBreakpoint(): void {
|
||||||
if ( process.env.DEV ) {
|
if ( process.env.DEV ) {
|
||||||
if ( window.divComponentsUpdate && Component.updateList != null ) {
|
const divComponentsUpdate = getDivComponentsUpdate();
|
||||||
|
|
||||||
|
if ( Component.updateList != null ) {
|
||||||
Promise.all( Component.updateList ).then( ( list ) => {
|
Promise.all( Component.updateList ).then( ( list ) => {
|
||||||
let accumCpu = 0.0;
|
let accumCpu = 0.0;
|
||||||
let accumGpu = 0.0;
|
let accumGpu = 0.0;
|
||||||
@@ -54,7 +57,7 @@ export class Component {
|
|||||||
} ).join( '\n' );
|
} ).join( '\n' );
|
||||||
|
|
||||||
const strAccum = `${ accumCpu.toFixed( 3 ) }, ${ accumGpu.toFixed( 3 ) } - UPDATE\n`;
|
const strAccum = `${ accumCpu.toFixed( 3 ) }, ${ accumGpu.toFixed( 3 ) } - UPDATE\n`;
|
||||||
window.divComponentsUpdate!.innerHTML = strAccum + strEach;
|
divComponentsUpdate.innerHTML = strAccum + strEach;
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
Component.updateList = [];
|
Component.updateList = [];
|
||||||
@@ -65,7 +68,9 @@ export class Component {
|
|||||||
|
|
||||||
public static resetDrawBreakpoint(): void {
|
public static resetDrawBreakpoint(): void {
|
||||||
if ( process.env.DEV ) {
|
if ( process.env.DEV ) {
|
||||||
if ( window.divComponentsDraw && Component.drawList != null ) {
|
const divComponentsDraw = getDivComponentsDraw();
|
||||||
|
|
||||||
|
if ( Component.drawList != null ) {
|
||||||
Promise.all( Component.drawList ).then( ( list ) => {
|
Promise.all( Component.drawList ).then( ( list ) => {
|
||||||
let accumCpu = 0.0;
|
let accumCpu = 0.0;
|
||||||
let accumGpu = 0.0;
|
let accumGpu = 0.0;
|
||||||
@@ -77,7 +82,7 @@ export class Component {
|
|||||||
} ).join( '\n' );
|
} ).join( '\n' );
|
||||||
|
|
||||||
const strAccum = `${ accumCpu.toFixed( 3 ) }, ${ accumGpu.toFixed( 3 ) } - DRAW\n`;
|
const strAccum = `${ accumCpu.toFixed( 3 ) }, ${ accumGpu.toFixed( 3 ) } - DRAW\n`;
|
||||||
window.divComponentsDraw!.innerHTML = strAccum + strEach;
|
divComponentsDraw.innerHTML = strAccum + strEach;
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
Component.drawList = [];
|
Component.drawList = [];
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { Component, ComponentDrawEvent, ComponentOptions } from './Component';
|
import { Component, ComponentDrawEvent, ComponentOptions } from './Component';
|
||||||
import { Geometry } from '../Geometry';
|
import { Geometry } from '../Geometry';
|
||||||
import { Material } from '../Material';
|
import { Material } from '../Material';
|
||||||
import { glCat } from '../canvas';
|
import { glCat } from '../../globals/canvas';
|
||||||
|
|
||||||
export enum MeshCull {
|
export enum MeshCull {
|
||||||
None,
|
None,
|
||||||
|
@@ -3,7 +3,7 @@ import { Geometry } from '../Geometry';
|
|||||||
import { Material } from '../Material';
|
import { Material } from '../Material';
|
||||||
import { RenderTarget } from '../RenderTarget';
|
import { RenderTarget } from '../RenderTarget';
|
||||||
import { TRIANGLE_STRIP_QUAD } from '@fms-cat/experimental';
|
import { TRIANGLE_STRIP_QUAD } from '@fms-cat/experimental';
|
||||||
import { glCat } from '../canvas';
|
import { glCat } from '../../globals/canvas';
|
||||||
|
|
||||||
const quadBuffer = glCat.createBuffer();
|
const quadBuffer = glCat.createBuffer();
|
||||||
quadBuffer.setVertexbuffer( new Float32Array( TRIANGLE_STRIP_QUAD ) );
|
quadBuffer.setVertexbuffer( new Float32Array( TRIANGLE_STRIP_QUAD ) );
|
||||||
|
130
src/main.ts
130
src/main.ts
@@ -1,13 +1,8 @@
|
|||||||
import { Automaton } from '@fms-cat/automaton';
|
import { canvas } from './globals/canvas';
|
||||||
import { AutomatonWithGUI } from '@fms-cat/automaton-with-gui';
|
|
||||||
import * as automatonFxs from './automaton-fxs/automatonFxs';
|
|
||||||
import { Music } from './Music';
|
|
||||||
import automatonData from './automaton.json';
|
|
||||||
import { canvas, glCat } from './heck/canvas';
|
|
||||||
import { Dog } from './heck/Dog';
|
import { Dog } from './heck/Dog';
|
||||||
import { CanvasRenderTarget } from './heck/CanvasRenderTarget';
|
import { CanvasRenderTarget } from './heck/CanvasRenderTarget';
|
||||||
import { Lambda } from './heck/components/Lambda';
|
import { Lambda } from './heck/components/Lambda';
|
||||||
import { randomTexture } from './utils/RandomTexture';
|
import { randomTexture } from './globals/randomTexture';
|
||||||
import { SphereParticles } from './entities/SphereParticles';
|
import { SphereParticles } from './entities/SphereParticles';
|
||||||
import { Swap, Vector3 } from '@fms-cat/experimental';
|
import { Swap, Vector3 } from '@fms-cat/experimental';
|
||||||
import { BufferRenderTarget } from './heck/BufferRenderTarget';
|
import { BufferRenderTarget } from './heck/BufferRenderTarget';
|
||||||
@@ -26,11 +21,11 @@ import { PixelSorter } from './entities/PixelSorter';
|
|||||||
import { IBLLUT } from './entities/IBLLUT';
|
import { IBLLUT } from './entities/IBLLUT';
|
||||||
import { EnvironmentMap } from './entities/EnvironmentMap';
|
import { EnvironmentMap } from './entities/EnvironmentMap';
|
||||||
import { Cube } from './entities/Cube';
|
import { Cube } from './entities/Cube';
|
||||||
|
import { music } from './globals/music';
|
||||||
|
import { automaton } from './globals/automaton';
|
||||||
|
import { getCheckboxActive } from './globals/dom';
|
||||||
|
|
||||||
// == music ========================================================================================
|
// == music ========================================================================================
|
||||||
const audio = new AudioContext();
|
|
||||||
const music = new Music( glCat, audio );
|
|
||||||
|
|
||||||
if ( process.env.DEV ) {
|
if ( process.env.DEV ) {
|
||||||
music.isPlaying = true;
|
music.isPlaying = true;
|
||||||
}
|
}
|
||||||
@@ -47,58 +42,6 @@ if ( process.env.DEV ) {
|
|||||||
canvas.style.left = '0';
|
canvas.style.left = '0';
|
||||||
canvas.style.top = '0';
|
canvas.style.top = '0';
|
||||||
canvas.style.width = 'calc( 100% - 240px )';
|
canvas.style.width = 'calc( 100% - 240px )';
|
||||||
|
|
||||||
window.divPath = document.createElement( 'div' );
|
|
||||||
document.body.appendChild( window.divPath );
|
|
||||||
window.divPath.style.position = 'fixed';
|
|
||||||
window.divPath.style.textAlign = 'right';
|
|
||||||
window.divPath.style.right = '8px';
|
|
||||||
window.divPath.style.bottom = '248px';
|
|
||||||
window.divPath.style.textShadow = '1px 1px 1px #ffffff';
|
|
||||||
|
|
||||||
window.divAutomaton = document.createElement( 'div' );
|
|
||||||
document.body.appendChild( window.divAutomaton );
|
|
||||||
window.divAutomaton.style.position = 'fixed';
|
|
||||||
window.divAutomaton.style.width = '100%';
|
|
||||||
window.divAutomaton.style.height = '240px';
|
|
||||||
window.divAutomaton.style.right = '0';
|
|
||||||
window.divAutomaton.style.bottom = '0';
|
|
||||||
|
|
||||||
window.checkActive = document.createElement( 'input' );
|
|
||||||
document.body.appendChild( window.checkActive );
|
|
||||||
window.checkActive.type = 'checkbox';
|
|
||||||
window.checkActive.checked = true;
|
|
||||||
window.checkActive.style.position = 'fixed';
|
|
||||||
window.checkActive.style.left = '8px';
|
|
||||||
window.checkActive.style.bottom = '248px';
|
|
||||||
|
|
||||||
window.divComponentsUpdate = document.createElement( 'div' );
|
|
||||||
document.body.appendChild( window.divComponentsUpdate );
|
|
||||||
window.divComponentsUpdate.style.whiteSpace = 'pre';
|
|
||||||
window.divComponentsUpdate.style.color = '#ffffff';
|
|
||||||
window.divComponentsUpdate.style.font = '500 10px Wt-Position-Mono';
|
|
||||||
window.divComponentsUpdate.style.position = 'fixed';
|
|
||||||
window.divComponentsUpdate.style.padding = '0';
|
|
||||||
window.divComponentsUpdate.style.boxSizing = 'border-box';
|
|
||||||
window.divComponentsUpdate.style.width = '240px';
|
|
||||||
window.divComponentsUpdate.style.height = 'calc( ( 100% - 240px ) * 0.5 )';
|
|
||||||
window.divComponentsUpdate.style.right = '0';
|
|
||||||
window.divComponentsUpdate.style.top = '0';
|
|
||||||
window.divComponentsUpdate.style.overflowY = 'scroll';
|
|
||||||
|
|
||||||
window.divComponentsDraw = document.createElement( 'div' );
|
|
||||||
document.body.appendChild( window.divComponentsDraw );
|
|
||||||
window.divComponentsDraw.style.whiteSpace = 'pre';
|
|
||||||
window.divComponentsDraw.style.color = '#ffffff';
|
|
||||||
window.divComponentsDraw.style.font = '500 10px Wt-Position-Mono';
|
|
||||||
window.divComponentsDraw.style.position = 'fixed';
|
|
||||||
window.divComponentsDraw.style.padding = '0';
|
|
||||||
window.divComponentsDraw.style.boxSizing = 'border-box';
|
|
||||||
window.divComponentsDraw.style.width = '240px';
|
|
||||||
window.divComponentsDraw.style.height = 'calc( ( 100% - 240px ) * 0.5 )';
|
|
||||||
window.divComponentsDraw.style.right = '0';
|
|
||||||
window.divComponentsDraw.style.top = 'calc( ( 100% - 240px ) * 0.5 )';
|
|
||||||
window.divComponentsDraw.style.overflowY = 'scroll';
|
|
||||||
} else {
|
} else {
|
||||||
canvas.style.position = 'fixed';
|
canvas.style.position = 'fixed';
|
||||||
canvas.style.left = '0';
|
canvas.style.left = '0';
|
||||||
@@ -117,53 +60,11 @@ if ( process.env.DEV ) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// == automaton ====================================================================================
|
// == scene ========================================================================================
|
||||||
let totalFrame = 0;
|
let totalFrame = 0;
|
||||||
let isInitialFrame = true;
|
let isInitialFrame = true;
|
||||||
|
|
||||||
let automaton: Automaton;
|
const dog = new Dog();
|
||||||
|
|
||||||
if ( process.env.DEV ) {
|
|
||||||
// this cast smells so bad
|
|
||||||
// https://github.com/FMS-Cat/automaton/issues/121
|
|
||||||
const automatonWithGUI = new AutomatonWithGUI(
|
|
||||||
automatonData,
|
|
||||||
{
|
|
||||||
gui: window.divAutomaton,
|
|
||||||
isPlaying: true,
|
|
||||||
fxDefinitions: automatonFxs,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
automatonWithGUI.on( 'play', () => { music.isPlaying = true; } );
|
|
||||||
automatonWithGUI.on( 'pause', () => { music.isPlaying = false; } );
|
|
||||||
automatonWithGUI.on( 'seek', ( { time } ) => {
|
|
||||||
music.time = Math.max( 0.0, time );
|
|
||||||
automaton.reset();
|
|
||||||
} );
|
|
||||||
|
|
||||||
if ( module.hot ) {
|
|
||||||
module.hot.accept( './automaton.json', () => {
|
|
||||||
// we probably don't need this feature for now...
|
|
||||||
// See: https://github.com/FMS-Cat/automaton/issues/120
|
|
||||||
// automatonWithGUI.deserialize( automatonData );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
automaton = automatonWithGUI;
|
|
||||||
} else {
|
|
||||||
// this cast smells so bad
|
|
||||||
// https://github.com/FMS-Cat/automaton/issues/121
|
|
||||||
automaton = new Automaton(
|
|
||||||
automatonData,
|
|
||||||
{
|
|
||||||
fxDefinitions: automatonFxs
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// == scene ========================================================================================
|
|
||||||
const dog = new Dog( music );
|
|
||||||
|
|
||||||
const canvasRenderTarget = new CanvasRenderTarget();
|
const canvasRenderTarget = new CanvasRenderTarget();
|
||||||
|
|
||||||
@@ -188,15 +89,10 @@ const environmentMap = new EnvironmentMap();
|
|||||||
dog.root.children.push( environmentMap.entity );
|
dog.root.children.push( environmentMap.entity );
|
||||||
|
|
||||||
// -- "objects" ------------------------------------------------------------------------------------
|
// -- "objects" ------------------------------------------------------------------------------------
|
||||||
const sphereParticles = new SphereParticles( {
|
const sphereParticles = new SphereParticles();
|
||||||
particlesSqrt: 256,
|
|
||||||
} );
|
|
||||||
dog.root.children.push( sphereParticles.entity );
|
dog.root.children.push( sphereParticles.entity );
|
||||||
|
|
||||||
const trails = new Trails( {
|
const trails = new Trails();
|
||||||
trails: 4096,
|
|
||||||
trailLength: 64,
|
|
||||||
} );
|
|
||||||
dog.root.children.push( trails.entity );
|
dog.root.children.push( trails.entity );
|
||||||
|
|
||||||
const rings = new Rings();
|
const rings = new Rings();
|
||||||
@@ -295,7 +191,6 @@ swap.swap();
|
|||||||
const glitch = new Glitch( {
|
const glitch = new Glitch( {
|
||||||
input: swap.i,
|
input: swap.i,
|
||||||
target: swap.o,
|
target: swap.o,
|
||||||
automaton,
|
|
||||||
} );
|
} );
|
||||||
dog.root.children.push( glitch.entity );
|
dog.root.children.push( glitch.entity );
|
||||||
|
|
||||||
@@ -303,7 +198,6 @@ swap.swap();
|
|||||||
const pixelSorter = new PixelSorter( {
|
const pixelSorter = new PixelSorter( {
|
||||||
input: swap.i,
|
input: swap.i,
|
||||||
target: swap.o,
|
target: swap.o,
|
||||||
automaton,
|
|
||||||
} );
|
} );
|
||||||
dog.root.children.push( pixelSorter.entity );
|
dog.root.children.push( pixelSorter.entity );
|
||||||
|
|
||||||
@@ -323,15 +217,17 @@ if ( process.env.DEV ) {
|
|||||||
|
|
||||||
// -- keyboards ------------------------------------------------------------------------------------
|
// -- keyboards ------------------------------------------------------------------------------------
|
||||||
if ( process.env.DEV ) {
|
if ( process.env.DEV ) {
|
||||||
|
const checkboxActive = getCheckboxActive();
|
||||||
|
|
||||||
window.addEventListener( 'keydown', ( event ) => {
|
window.addEventListener( 'keydown', ( event ) => {
|
||||||
if ( event.key === 'Escape' ) { // panic button
|
if ( event.key === 'Escape' ) { // panic button
|
||||||
dog.root.active = false;
|
dog.root.active = false;
|
||||||
music.isPlaying = false;
|
music.isPlaying = false;
|
||||||
window.checkActive!.checked = false;
|
checkboxActive.checked = false;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
window.checkActive!.addEventListener( 'input', ( event: any ) => {
|
checkboxActive.addEventListener( 'input', ( event: any ) => {
|
||||||
dog.root.active = event.target.checked;
|
dog.root.active = event.target.checked;
|
||||||
music.isPlaying = event.target.checked;
|
music.isPlaying = event.target.checked;
|
||||||
} );
|
} );
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import { GLCat, GLCatTexture } from '@fms-cat/glcat-ts';
|
|
||||||
import { Xorshift } from '@fms-cat/experimental';
|
import { Xorshift } from '@fms-cat/experimental';
|
||||||
import { gl, glCat } from '../heck/canvas';
|
import GLCat, { GLCatTexture } from '@fms-cat/glcat-ts';
|
||||||
import { RANDOM_RESOLUTION, STATIC_RANDOM_RESOLUTION } from '../config';
|
import { gl } from '../globals/canvas';
|
||||||
|
|
||||||
export class RandomTexture {
|
export class RandomTexture {
|
||||||
private __texture: GLCatTexture<WebGL2RenderingContext>;
|
private __texture: GLCatTexture<WebGL2RenderingContext>;
|
||||||
@@ -53,17 +52,3 @@ export class RandomTexture {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const randomTexture = new RandomTexture(
|
|
||||||
glCat,
|
|
||||||
RANDOM_RESOLUTION[ 0 ],
|
|
||||||
RANDOM_RESOLUTION[ 1 ]
|
|
||||||
);
|
|
||||||
randomTexture.update();
|
|
||||||
|
|
||||||
export const randomTextureStatic = new RandomTexture(
|
|
||||||
glCat,
|
|
||||||
STATIC_RANDOM_RESOLUTION[ 0 ],
|
|
||||||
STATIC_RANDOM_RESOLUTION[ 1 ]
|
|
||||||
);
|
|
||||||
randomTextureStatic.update();
|
|
||||||
|
7
src/window.d.ts
vendored
7
src/window.d.ts
vendored
@@ -1,7 +0,0 @@
|
|||||||
interface Window {
|
|
||||||
divPath?: HTMLDivElement;
|
|
||||||
divAutomaton?: HTMLDivElement;
|
|
||||||
checkActive?: HTMLInputElement;
|
|
||||||
divComponentsUpdate?: HTMLDivElement;
|
|
||||||
divComponentsDraw?: HTMLDivElement;
|
|
||||||
}
|
|
Reference in New Issue
Block a user