This project initializes a Node.js package for building and testing a web application. It uses Webpack for managing debug and production builds.
- Initialize the project:
npm init
- Install dependencies:
npm install
-
Debug Build
npm run build:debug
This command (
"build:debug": "npx webpack --config webpack.config.debug.js"
) generates a debug build with live page updates. -
Production Build
npm run build:production
This command (
"build:production": "npx webpack --config webpack.config.production.js"
) generates a final production build indist.production
, withmain.min.js
as the output.
-
Entry Point:
App.ts
- Initializes main classes:
const view = new MainView(app); const model = new MainModel(); const controller = new MainController(); model.init(view); controller.init(model); app.ticker.add((time) => { view.update(); view.render(); TWEEN.update(); });
- Initializes main classes:
-
Main Classes:
MainView
: Manages visual componentscontHighlight
,contGraphics
, andcontGraphicsFinal
: Graphics containers used to draw lines and connections, cleared each frame.cont
: ContainsSectorView
instances, each managing animatedBlockView
elements.
MainModel
: Handles data collection and management.MainController
: ConnectsMainView
andMainModel
.
Create texture for the block in MainView.ts
typescript let hx = new Graphics(); hx.rect(0, 0, 80, 80) .fill(Config.colors.blockInactive) CustomTextures.textures.hex = app.renderer.generateTexture(hx);
Use https://pixijs.com/8.x/guides/components/graphics API to create new shape form
To use custom sprite it need to load it first as image
await PIXI.Assets.load('sample.png');
let sprite = PIXI.Sprite.from('sample.png');
And use in BlockView.ts instead of
const obj = new Sprite(CustomTextures.textures.hex);
obj.anchor.set(0.5);
this.addChild(obj)
to
const obj = PIXI.Sprite.from('sample.png');
obj.anchor.set(0.5);
this.addChild(obj)
BlockView has only 1 animation of moving to own positions
this.moveTo = (pos: number) => {
if (fin != pos) {
fin = pos;
gsap.to(this, {
y: fin,
duration: 0.5, // продолжительность анимации в секундах
ease: "sine.out",
});
}
}
All animations based on GSAP
All sectors with blocks inside are moving in MainView.ts in 'cont' container, so, we move only container with all sectors
let moveSectorsTo = (instant = false) => {
let val: number;
let speed = Config.SECTOR_MOVE_SPEED;
if (active)
val = Config.DEFAULT_WIDTH / 2 - (this.sectors[selectedSector].x) * zoom;
else
val = Config.DEFAULT_WIDTH / 2 - (this.sectors[selectedSector].x + 100) * zoom;
if (instant)
speed = 0;
//stop all animations of existing containers
gsap.killTweensOf([
contHighlight,
contGraphics,
contGraphicsFinal,
cont
]);
//start again and move to new position 'val' with speed 'speed'
gsap.to([
contHighlight,
contGraphics,
contGraphicsFinal,
cont
], {
x: val,
duration: speed, // продолжительность анимации в секундах
ease: easeType,
});
}