Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/asset/plugins/asset.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @import { Constructor } from '../../type/index.js' */

import { App, Plugin } from '../../app/index.js'
import { AppSchedule } from '../../core/index.js'
import { AppSchedule, CoreSystems } from '../../core/index.js'
import { EventPlugin } from '../../event/index.js'
import { typeid, typeidGeneric } from '../../type/index.js'
import { Assets } from '../core/index.js'
Expand Down Expand Up @@ -58,23 +58,27 @@ export class AssetPlugin extends Plugin {
.registerSystem({
label: `updateAssetEvents<${typeid(asset)}>`,
schedule: AppSchedule.Update,
systemGroup: CoreSystems.End,
system: updateAssetEvents(asset, events)
})
.registerSystem({
label: `unloadDroppedAssets<${typeid(events.dropped)}>`,
schedule: AppSchedule.Update,
systemGroup: CoreSystems.End,
system: unloadDroppedAssets(events.dropped)
})
}

app.registerSystem({
label: `registerAssetOnAssetServer<${typeid(asset)}>`,
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.Start,
system: registerAssetOnAssetServer(asset)
})
app.registerSystem({
label: `registerAssetTypes<${typeid(asset)}>`,
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.Start,
system: registerAssetTypes(asset)
})
world.setResourceByTypeId(
Expand Down
10 changes: 5 additions & 5 deletions src/asset/plugins/assetServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EventPlugin } from '../../event/index.js'
import { AssetServer } from '../resources/index.js'
import { AssetLoadFail, AssetLoadSuccess } from '../events/index.js'
import { updateAssets, updateAssetLoadEvents, logFailedLoads, registerAssetServerTypes } from '../systems/index.js'
import { AppSchedule } from '../../core/index.js'
import { AppSchedule, CoreSystems } from '../../core/index.js'

export class AssetServerPlugin extends Plugin {

Expand All @@ -19,9 +19,9 @@ export class AssetServerPlugin extends Plugin {
.registerPlugin(new EventPlugin({
event: AssetLoadFail
}))
.registerSystem({ schedule: AppSchedule.Startup, system: registerAssetServerTypes })
.registerSystem({ schedule: AppSchedule.Update, system: updateAssets })
.registerSystem({ schedule: AppSchedule.Update, system: updateAssetLoadEvents })
.registerSystem({ schedule: AppSchedule.Update, system: logFailedLoads })
.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerAssetServerTypes })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateAssets })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateAssetLoadEvents })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: logFailedLoads })
}
}
3 changes: 2 additions & 1 deletion src/asset/plugins/parser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @import {Constructor} from '../../type/index.js' */
import { App, Plugin } from '../../app/index.js'
import { AppSchedule } from '../../core/index.js'
import { AppSchedule, CoreSystems } from '../../core/index.js'
import { typeid, typeidGeneric } from '../../type/index.js'
import { Parser } from '../core/index.js'
import { registerAssetParserOnAssetServer } from '../systems/index.js'
Expand Down Expand Up @@ -44,6 +44,7 @@ export class AssetParserPlugin extends Plugin {
.registerSystem({
label: `registerAssetParserOnAssetServer<${typeid(asset)}>`,
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.Start,
system: registerAssetParserOnAssetServer(asset, parser)
})
}
Expand Down
13 changes: 11 additions & 2 deletions src/command/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App, Plugin } from '../app/index.js'
import { AppSchedule } from '../core/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { World } from '../ecs/index.js'
import { CommandQueue } from './resources/index.js'

Expand All @@ -11,7 +11,16 @@ export class CommandsPlugin extends Plugin {
register(app) {
app
.setResource(new CommandQueue())
.registerSystem({ schedule: AppSchedule.Update, system: executeCommands })
.registerSystem({
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.End,
system: executeCommands
})
.registerSystem({
schedule: AppSchedule.Update,
systemGroup: CoreSystems.End,
system: executeCommands
})
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/diagnostic/entitycount.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App } from '../app/index.js'
import { AppSchedule } from '../core/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { World, Entity, Query } from '../ecs/index.js'

export class EntityCountDiagnosticPlugin {
Expand All @@ -9,8 +9,8 @@ export class EntityCountDiagnosticPlugin {
*/
register(app) {
app
.registerSystem({ schedule: AppSchedule.Startup, system: setUpUI })
.registerSystem({ schedule: AppSchedule.Update, system: updateEntityCount })
.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: setUpUI })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateEntityCount })
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/diagnostic/fpsdebugger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App, Plugin } from '../app/index.js'
import { AppSchedule } from '../core/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { World } from '../ecs/index.js'
import { TimerMode, VirtualClock } from '../time/index.js'
import { RAFTimer } from './resources/index.js'
Expand All @@ -13,10 +13,10 @@ export class FPSDebugger extends Plugin {
register(app) {
app
.setResource(new RAFTimer({ duration: 1, mode: TimerMode.Repeat }))
.registerSystem({ schedule: AppSchedule.Startup, system: registerFpsDebuggerTypes })
.registerSystem({ schedule: AppSchedule.Startup, system: setUpUI })
.registerSystem({ schedule: AppSchedule.Update, system: updateFPSCounter })
.registerSystem({ schedule: AppSchedule.Update, system: updateRAFTimer })
.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerFpsDebuggerTypes })
.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: setUpUI })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateFPSCounter })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateRAFTimer })
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/event/plugin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/** @import { Constructor } from '../type/index.js'*/

import { App, Plugin } from '../app/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { makeEventClear, registerEventTypes } from './systems/index.js'
import { Events } from './core/index.js'
import { typeid, typeidGeneric } from '../type/index.js'
import { AppSchedule } from '../core/index.js'

/**
* @template T
Expand Down Expand Up @@ -46,18 +46,18 @@ export class EventPlugin extends Plugin {
.registerSystem({
label: `registerEventTypes<${typeid(event)}>`,
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.Start,
system: registerEventTypes(event)
})
.getWorld()
.setResourceByTypeId(name, new Events())

if (this.autoClearEvent) {
app
.registerSystemGroup({ label: event, schedule: AppSchedule.Update })
.registerSystem({
label: `clearEvents<${typeid(event)}>`,
schedule: AppSchedule.Update,
systemGroup: event,
systemGroup: CoreSystems.End,
system: makeEventClear(name)
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/keyboard/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Events } from '../event/index.js'
import { World } from '../ecs/index.js'
import { KeyCode } from './core/key.js'
import { typeidGeneric } from '../type/index.js'
import { AppSchedule } from '../core/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { registerKeyboardTypes } from './systems/index.js'

export class KeyboardPlugin extends Plugin {
Expand All @@ -16,8 +16,8 @@ export class KeyboardPlugin extends Plugin {
register(app) {
app
.setResource(new Keyboard())
.registerSystem({ schedule: AppSchedule.Startup, system: registerKeyboardTypes })
.registerSystem({ schedule: AppSchedule.Update, system: updateKeyBoard })
.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerKeyboardTypes })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: updateKeyBoard })
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/mouse/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Events } from '../event/index.js'
import { PointerDown, PointerMove, PointerUp } from '../window/index.js'
import { Vector2 } from '../math/index.js'
import { typeidGeneric } from '../type/index.js'
import { AppSchedule } from '../core/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { registerMouseTypes } from './systems/index.js'

export class MousePlugin extends Plugin {
Expand All @@ -19,9 +19,9 @@ export class MousePlugin extends Plugin {
app
.setResource(new Mouse())
.setResource(new MouseButtons())
.registerSystem({ schedule: AppSchedule.Startup, system: registerMouseTypes })
.registerSystem({ schedule: AppSchedule.Update, system: updateMouse })
.registerSystem({ schedule: AppSchedule.Update, system: updateMouseButtons })
.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerMouseTypes })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: updateMouse })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: updateMouseButtons })
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/profiler/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TimerMode, VirtualClock } from '../time/index.js'
import { App, Plugin } from '../app/index.js'
import { World } from '../ecs/index.js'
import { warn } from '../logger/index.js'
import { AppSchedule } from '../core/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { registerProfilerTypes } from './systems/index.js'

export class ProfilerPlugin extends Plugin {
Expand All @@ -14,10 +14,10 @@ export class ProfilerPlugin extends Plugin {
register(app) {
app.setResource(new Profiler())
app.setResource(new ProfilerTimer({ duration: 1, mode: TimerMode.Repeat }))
app.registerSystem({ schedule: AppSchedule.Startup, system: registerProfilerTypes })
app.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerProfilerTypes })
setupProfileViewer(document.body)
app.registerSystem({ schedule: AppSchedule.Update, system: updateProfileViewer })
app.registerSystem({ schedule: AppSchedule.Update, system: updateProfileTimer })
app.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateProfileViewer })
app.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateProfileTimer })
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/render-canvas2d/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/** @import { Canvas2DFunction } from '../types/index.js' */

import { App, Plugin } from '../../app/index.js'
import { typeidGeneric } from '../../type/index.js'
import { typeid, typeidGeneric } from '../../type/index.js'
import { genrender } from '../systems/index.js'
import { Material } from '../../render-core/index.js'
import { AppSchedule } from '../../core/index.js'
import { AppSchedule, CoreSystems } from '../../core/index.js'

/**
* @template {Material} T
Expand Down Expand Up @@ -39,7 +39,12 @@ export class Canvas2DMaterialPlugin extends Plugin {
register(app) {
const { material, update } = this

app.registerSystem({ schedule: AppSchedule.Update, system: genrender(material, update) })
app.registerSystem({
schedule: AppSchedule.Update,
label: `renderToCanvas2d<${typeid(material)}>`,
systemGroup: CoreSystems.PostMain,
system: genrender(material, update)
})
}

name() {
Expand Down
4 changes: 2 additions & 2 deletions src/render-core/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App, Plugin } from '../app/index.js'
import { AppSchedule } from '../core/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { AssetParserPlugin, AssetPlugin, Assets } from '../asset/index.js'
import { BasicMaterial2D, BasicMaterial3D, Camera, Meshed } from './components/index.js'
import { Mesh, Shader, Image, BasicMaterial } from './assets/index.js'
Expand Down Expand Up @@ -33,7 +33,7 @@ export class RenderCorePlugin extends Plugin {
app
.registerType(Meshed)
.registerType(Camera)
.registerSystem({ schedule: AppSchedule.Startup, system: registerRenderCoreTypes })
.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerRenderCoreTypes })
.registerPlugin(new AssetPlugin({
asset: Image,
events: {
Expand Down
18 changes: 15 additions & 3 deletions src/render-core/plugins/material.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @import { Constructor, TypeId } from '../../type/index.js' */

import { App, Plugin } from '../../app/index.js'
import { AppSchedule } from '../../core/index.js'
import { AppSchedule, CoreSystems } from '../../core/index.js'
import { typeid, typeidGeneric } from '../../type/index.js'
import { Material } from '../assets/index.js'
import { Material2D, Material3D } from '../components/index.js'
Expand Down Expand Up @@ -43,11 +43,13 @@ export class Material2DPlugin extends Plugin {
.registerType(component)
.registerSystem({
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.Start,
label: `registerMaterialTypes<${typeid(asset)}>`,
system: registerMaterialTypes(component, asset)
})
.registerSystem({
schedule: AppSchedule.Update,
systemGroup: CoreSystems.PostMain,
label: `registerMaterialTypes<${typeid(asset)}>`,
system: genBinRenderables2D(asset, component)
})
Expand Down Expand Up @@ -95,8 +97,18 @@ export class Material3DPlugin extends Plugin {

app
.registerType(component)
.registerSystem({ schedule: AppSchedule.Startup, system: registerMaterialTypes(component, asset) })
.registerSystem({ schedule: AppSchedule.Update, system: genBinRenderables3D(asset, component) })
.registerSystem({
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.Start,
label: `initRenderPipeline<${typeid(asset)}>`,
system: registerMaterialTypes(component, asset)
})
.registerSystem({
schedule: AppSchedule.Update,
systemGroup: CoreSystems.PostMain,
label: `binRenders3D<${typeid(asset)}>`,
system: genBinRenderables3D(asset, component)
})
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/render-webgl/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App, Plugin } from '../app/index.js'
import { AppSchedule } from '../core/index.js'
import { AppSchedule, CoreSystems } from '../core/index.js'
import { Entity, Query, World } from '../ecs/index.js'
import { warn } from '../logger/index.js'
import { MeshAttribute, ProgramCache, BasicMaterial } from '../render-core/index.js'
Expand All @@ -25,15 +25,15 @@ export class WebglRendererPlugin extends Plugin {
.setResource(new ClearColor())
.setResource(attribute)
.setResource(new WebglProgramCache())
.registerSystem({ schedule: AppSchedule.Startup, system: registerWebglTypes })
.registerSystem({ schedule: AppSchedule.Update, system: registerBuffers })
.registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerWebglTypes })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: registerBuffers })
.registerPlugin(new WebglMaterialPlugin({
material: BasicMaterial,
vertex3d: basicMaterial3DVertex,
fragment3d: basicMaterial3DFragment
}))
.registerSystem({ schedule: AppSchedule.Update, system: disposeDroppedMeshes })
.registerSystem({ schedule: AppSchedule.Update, system: queueMeshes })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.PostMain, system: disposeDroppedMeshes })
.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.PostMain, system: queueMeshes })
}
}

Expand Down
24 changes: 20 additions & 4 deletions src/render-webgl/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import { App } from '../../app/app.js'
import { AppSchedule } from '../../core/core/schedules.js'
import { typeidGeneric } from '../../type/index.js'
import { CoreSystems } from '../../core/core/systemgroups.js'
import { typeid, typeidGeneric } from '../../type/index.js'
import { Material } from '../../render-core/index.js'
import { genRegisterBuffer, genRender, genRenderPipeline } from '../systems/index.js'

Expand Down Expand Up @@ -50,9 +51,24 @@ export class WebglMaterialPlugin {
const { material, vertex3d, fragment3d } = this

app
.registerSystem({ schedule: AppSchedule.Startup, system: genRegisterBuffer(material) })
.registerSystem({ schedule: AppSchedule.Update, system: genRenderPipeline(material, vertex3d, fragment3d) })
.registerSystem({ schedule: AppSchedule.Update, system: genRender(material) })
.registerSystem({
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.Start,
label: `registerBuffers<${typeid(material)}>`,
system: genRegisterBuffer(material)
})
.registerSystem({
schedule: AppSchedule.Update,
systemGroup: CoreSystems.PostMain,
label: `initRenderPipeline<${typeid(material)}>`,
system: genRenderPipeline(material, vertex3d, fragment3d)
})
.registerSystem({
schedule: AppSchedule.Update,
systemGroup: CoreSystems.PostMain,
label: `renderToWebgl<${typeid(material)}>`,
system: genRender(material)
})
}

name() {
Expand Down
Loading
Loading