Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: v8 examples update #56

Merged
merged 99 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
62efc86
Restructuring: Move Tutorial and Playground into the Docusaurus Docs …
bbazukun123 Dec 6, 2023
ab917fb
Merge branch 'main' into website-restructuring
bbazukun123 Dec 6, 2023
6174db9
Fix main container styling in coding mode for full-screen
bbazukun123 Dec 14, 2023
32859ae
Chore: Website Restructuring
bbazukun123 Dec 17, 2023
64c7068
Updated content generation scripts
bbazukun123 Dec 18, 2023
932e75c
Minor fixes
bbazukun123 Dec 18, 2023
150eeeb
Chore: Website Versioning
bbazukun123 Dec 18, 2023
dc13ba1
Chore: Create v7.x Snapshot + Make Working Docs the Pre-Release v8
bbazukun123 Dec 18, 2023
512aafe
Versions page fixes
bbazukun123 Dec 18, 2023
7bd5b84
Merge branch 'chore-website-versioning' into chore-website-v7-snapshot
bbazukun123 Dec 18, 2023
05d2da4
Tweaked Sandpack Dependencies Config
bbazukun123 Dec 19, 2023
da9127f
Hotfix: Restructure Source Examples and Tutorial
bbazukun123 Dec 19, 2023
af6c7e0
Type hotfix
bbazukun123 Dec 19, 2023
265ba3c
Pre-Release v8 Examples Update
bbazukun123 Dec 21, 2023
fd9b693
Added back parcel-bundler for all pixi versions
bbazukun123 Dec 21, 2023
959131a
Merge branch 'hotfix-versioned-code-content-handling' into pre-releas…
bbazukun123 Dec 21, 2023
281e5fd
More examples updated
bbazukun123 Dec 21, 2023
a504c1d
More examples update
bbazukun123 Dec 22, 2023
081c5a5
Updated/Added/Removed more examples
bbazukun123 Dec 22, 2023
5aaf110
Reverted conditioned babel core dev dependency
bbazukun123 Dec 22, 2023
3ed15fe
Merge branch 'hotfix-versioned-code-content-handling' into pre-releas…
bbazukun123 Dec 22, 2023
6204e64
Pre-update Shader examples
bbazukun123 Dec 22, 2023
2b7cc43
Revert Ticker.shared back to app.ticker
bbazukun123 Dec 22, 2023
a30aa56
Lint fix
bbazukun123 Dec 22, 2023
ac3e218
Chore: Upgrade Working Docs to use PixiJS v8.0.0-rc.1
bbazukun123 Jan 4, 2024
54193f7
Merge branch 'chore-upgrade-to-v8-rc1' into pre-release-v8-examples
bbazukun123 Jan 4, 2024
76b48f8
Remove v8.0.0-rc (old) content
bbazukun123 Jan 5, 2024
e7d7612
Simplify source versioning for examples and tutorials
bbazukun123 Jan 8, 2024
18c9514
Bump up to v8.0.0-rc.2
bbazukun123 Jan 8, 2024
0c86ca2
Merge branch 'chore-upgrade-to-v8-rc1' into pre-release-v8-examples
bbazukun123 Jan 8, 2024
62e0148
Type fix
bbazukun123 Jan 8, 2024
55ed9c0
Merge branch 'chore-upgrade-to-v8-rc1' into pre-release-v8-examples
bbazukun123 Jan 8, 2024
f8129fd
Add ghtoken ignore
bbazukun123 Jan 11, 2024
437d439
Merge branch 'chore-upgrade-to-v8-rc1' into pre-release-v8-examples
bbazukun123 Jan 11, 2024
c0c34a3
Fix Versioned Links
bbazukun123 Jan 13, 2024
d625908
Merge branch 'chore-upgrade-to-v8-rc1' into pre-release-v8-examples
bbazukun123 Jan 13, 2024
1e5f5c0
Upgrade to RC4
bbazukun123 Jan 13, 2024
2818145
Merge branch 'chore-upgrade-to-v8-rc1' into pre-release-v8-examples
bbazukun123 Jan 13, 2024
892d599
Chore: Website Versioning Scripts (#52)
bbazukun123 Jan 15, 2024
2b4fa80
Merge branch 'main' into website-restructuring
bbazukun123 Jan 15, 2024
e975142
Upgrade to RC4
bbazukun123 Jan 15, 2024
b635448
No footer on example pages
bbazukun123 Jan 15, 2024
1182ee6
Update v7.x versioned docs
bbazukun123 Jan 15, 2024
7254989
Use semver to pick the latest version instead of relying on the lates…
bbazukun123 Jan 15, 2024
fb68d61
Update Versions Page + Add devs and unmaintained versions
bbazukun123 Jan 16, 2024
83c4601
More readme update
bbazukun123 Jan 16, 2024
18dbf9b
Allowing user to customize pixi version label
bbazukun123 Jan 16, 2024
83f9bc2
Add the ability to manage generic snapshots
bbazukun123 Jan 17, 2024
a554482
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 17, 2024
972fa6b
Combine gitignores into the root one
bbazukun123 Jan 17, 2024
57b2e7e
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 17, 2024
496bea0
Updated Mesh and Shaders Section
bbazukun123 Jan 17, 2024
0d08e2e
Remove Nested Boundary with Projection Example
bbazukun123 Jan 17, 2024
3222299
Remove 7.3.2
bbazukun123 Jan 17, 2024
c04cb9b
Update generate example docs script to fix sidebar names
bbazukun123 Jan 17, 2024
8e398d9
Merge branch 'main' into website-restructuring
bbazukun123 Jan 19, 2024
bbb6630
Add ability to add extra packages to the playground
bbazukun123 Jan 19, 2024
914d7b7
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 19, 2024
c28cf94
Split out Triangle example into multiple files
bbazukun123 Jan 19, 2024
615daff
Update examples config to allow multiple files
bbazukun123 Jan 19, 2024
45c6d13
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 19, 2024
8bb5e0c
Adapt syntax highlighting on tab switches
bbazukun123 Jan 19, 2024
2449ce4
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 19, 2024
c1c4e01
Extract multi-file handling into a useCodeSource function
bbazukun123 Jan 19, 2024
f198664
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 19, 2024
a3bbd5e
Split long examples into multiple files
bbazukun123 Jan 20, 2024
113de35
Allow active file override with '$'
bbazukun123 Jan 20, 2024
28e29bd
Editor tutorial code change fix
bbazukun123 Jan 20, 2024
aa4628b
Allow extra packages on tutorial + add babel plugin
bbazukun123 Jan 20, 2024
5d0356e
Resolve conflict
bbazukun123 Jan 20, 2024
4a4be31
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 20, 2024
b45d2bd
Fix editor styling and persisting playground changes
bbazukun123 Jan 23, 2024
7e488de
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 23, 2024
50e3d01
Updated editor now keep persisted changes on all visible files + Fix …
bbazukun123 Jan 24, 2024
476282b
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 24, 2024
168162e
Tabs style update and fixes
bbazukun123 Jan 24, 2024
e0abe85
Upgrade to RC5
bbazukun123 Jan 24, 2024
89bc7e8
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 24, 2024
59790fb
Remove unused types and functions
bbazukun123 Jan 24, 2024
009eef4
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 24, 2024
017952c
Fix tab scroll
bbazukun123 Jan 24, 2024
60d4cac
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 24, 2024
114bd74
Fix texture url
bbazukun123 Jan 24, 2024
b6adc4c
Lint Fix
bbazukun123 Jan 24, 2024
3977f7a
Remove ShaderToy Filter Render Texture Example
bbazukun123 Jan 25, 2024
f3a29ec
Update Instanced Geometry + Multipass Mesh Codes
bbazukun123 Jan 25, 2024
8805bad
Bump up to RC6
bbazukun123 Jan 27, 2024
073e583
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Jan 27, 2024
79883db
Uncomment in instanced geometry
bbazukun123 Jan 27, 2024
66415a6
Fix uniform float type
bbazukun123 Jan 29, 2024
bd8f393
fix up the custom shaders for gl
GoodBoyDigital Feb 6, 2024
91f2626
Upgrade to RC7
bbazukun123 Feb 6, 2024
4cc153c
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Feb 6, 2024
163ee86
Updated v7.x to latest
bbazukun123 Feb 6, 2024
fc82dd8
Merge branch 'website-restructuring' into pre-release-v8-examples
bbazukun123 Feb 6, 2024
10ef838
add more examples for v8 (#71)
GoodBoyDigital Feb 22, 2024
7de3d0b
Merge branch 'v8' into pre-release-v8-examples
Zyie Feb 22, 2024
c788801
undo change
Zyie Feb 22, 2024
5082a4e
remove file
Zyie Feb 22, 2024
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ yarn-error.log*

scripts/pixiVersions.json

.ghtoken
.ghtoken
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ $ npm run switch-snapshot-pixi-version-config

where both come with an interactive list of all the snapshots for selection to be actioned on accordingly.

The `update-pixi-version-configs` script is also called pre-build and pre-deploy to update all the outdated labels or metadata on the `pixi-version.json` config on all the docs directories.
The `update-pixi-version-configs` script is also called pre-build and pre-deploy to update all the outdated labels or metadata on the `pixi-version.json` config on all the docs directories.
4 changes: 1 addition & 3 deletions scripts/generate-example-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,13 @@ async function go()
'hide_table_of_contents: true',
'hide_edit_this_page: true',
`sidebar_position: ${sidebarPosition++}`,
'hide_title: true',
'custom_edit_url: null',
`title: ${exampleTitle}`,
'---',
'<!-- AUTO-GENERATED BY [generate-example-docs] script -->',
'import Example from \'@site/src/components/Example/index\';',
'import version from \'../../pixi-version.json\';',
'',
`# ${exampleTitle}`,
'',
`<Example id="${exampleKey}" pixiVersion={version}/>`,
'',
].join('\n');
Expand Down
3 changes: 0 additions & 3 deletions src/examples/v7.0.0/events/nestedBoundaryWithProjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class Projector extends PIXI.DisplayObject

// Then bring global coords into content's world
this.worldTransform.applyInverse(to.global, to.global);
// TODO: Remove after https://github.com/pixijs/pixi.js/pull/7381
// is merged!
to.target = this.boundary.hitTest(to.global.x, to.global.y);
};

// Propagate these events down into the content's scene graph!
Expand Down
43 changes: 43 additions & 0 deletions src/examples/v8.0.0/advanced/spinners/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Application, Assets, Container, Sprite, Point, Graphics } from 'pixi.js';
import { generateSpinner1 } from './spinner1';
import { generateSpinner2 } from './spinner2';
import { generateSpinner3 } from './spinner3';
import { generateSpinner4 } from './spinner4';
import { generateSpinner5 } from './spinner5';

(async () =>
{
// Create a new application
const app = new Application();

// Initialize the application
await app.init({ antialias: true, background: '#1099bb', resizeTo: window });

// Append the application canvas to the document body
document.body.appendChild(app.canvas);

// Load the textures
await Assets.load([
'https://pixijs.com/assets/bg_scene_rotate.jpg',
'https://pixijs.com/assets/bg_rotate.jpg',
'https://pixijs.com/assets/circle.png',
]);

const onTick = [
generateSpinner1(app, new Point(50, 50)),
generateSpinner2(app, new Point(160, 50)),
generateSpinner3(app, new Point(270, 50)),
generateSpinner4(app, new Point(380, 50)),
generateSpinner5(app, new Point(490, 50)),
];

// Listen for animate update
app.ticker.add((time) =>
{
// Call tick handling for each spinner.
onTick.forEach((cb) =>
{
cb(time.deltaTime);
});
});
})();
40 changes: 40 additions & 0 deletions src/examples/v8.0.0/advanced/spinners/intersect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Helper functions

line intercept math by Paul Bourke http://paulbourke.net/geometry/pointlineplane/
Determine the intersection point of two line segments
Return FALSE if the lines don't intersect

Code modified from original to match pixi examples linting rules.
*/
export function intersect(x1, y1, x2, y2, x3, y3, x4, y4)
{
// Check if none of the lines are of length 0
if ((x1 === x2 && y1 === y2) || (x3 === x4 && y3 === y4))
{
return false;
}

const denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);

// Lines are parallel
if (denominator === 0)
{
return false;
}

const ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denominator;
const ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denominator;

// is the intersection along the segments
if (ua < 0 || ua > 1 || ub < 0 || ub > 1)
{
return false;
}

// Return a object with the x and y coordinates of the intersection
const x = x1 + ua * (x2 - x1);
const y = y1 + ua * (y2 - y1);

return { x, y };
}
99 changes: 99 additions & 0 deletions src/examples/v8.0.0/advanced/spinners/spinner1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { Container, Graphics, Sprite } from 'pixi.js';
import { intersect } from './intersect';

/* ---------------------------------------
Spinner 1. Square with radial completion.
-------------------------------------- */
export function generateSpinner1(app, position)
{
const container = new Container();

container.position = position;
app.stage.addChild(container);

const base = Sprite.from('https://pixijs.com/assets/bg_scene_rotate.jpg');
const size = 100;

base.width = size;
base.height = size;

const bottom = Sprite.from('https://pixijs.com/assets/bg_rotate.jpg');

bottom.width = size;
bottom.height = size;

const mask = new Graphics();

mask.position.set(size / 2, size / 2);
base.mask = mask;
window.mask = mask;

container.addChild(bottom);
container.addChild(base);
container.addChild(mask);

let phase = 0;

return (delta) =>
{
// Update phase
phase += delta / 60;
phase %= Math.PI * 2;

// Calculate target point.
const x = Math.cos(phase - Math.PI / 2) * size;
const y = Math.sin(phase - Math.PI / 2) * size;

const segments = [
[-size / 2, -size / 2, size / 2, -size / 2], // top segment
[size / 2, -size / 2, size / 2, size / 2], // right
[-size / 2, size / 2, size / 2, size / 2], // bottom
[-size / 2, -size / 2, -size / 2, size / 2], // left
];

// Find the intersecting segment.
let intersection = null;
let winding = 0;

for (let i = 0; i < segments.length; i++)
{
const segment = segments[i];
const hit = intersect(0, 0, x, y, segment[0], segment[1], segment[2], segment[3]);

if (hit)
{
intersection = hit;
if (i === 0) winding = hit.x > 0 ? 0 : 4;
else winding = i;
break;
}
}

const corners = [
size / 2,
-size / 2, // Top right
size / 2,
size / 2, // Bottom right
-size / 2,
size / 2, // Bottom left
-size / 2,
-size / 2, // Top left,
0,
-size / 2, // End point
];

// Redraw mask
mask.clear()
.moveTo(0, -size / 2)
.lineTo(0, 0)
.lineTo(intersection.x, intersection.y);

// fill the corners
for (let i = winding; i < corners.length / 2; i++)
{
mask.lineTo(corners[i * 2], corners[i * 2 + 1]);
}

mask.fill({ color: 0xff0000 });
};
}
47 changes: 47 additions & 0 deletions src/examples/v8.0.0/advanced/spinners/spinner2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { Container, Sprite } = require('pixi.js');

/* -----------------------
Spinner 2. Scaling balls.
---------------------- */
export function generateSpinner2(app, position)
{
const container = new Container();

container.position = position;
app.stage.addChild(container);

const size = 100;
const ballAmount = 7;
const balls = [];

for (let i = 0; i < ballAmount; i++)
{
const ball = Sprite.from('https://pixijs.com/assets/circle.png');

ball.anchor.set(0.5);
container.addChild(ball);
ball.position.set(
size / 2 + (Math.cos((i / ballAmount) * Math.PI * 2) * size) / 3,
size / 2 + (Math.sin((i / ballAmount) * Math.PI * 2) * size) / 3,
);
balls.push(ball);
}

let phase = 0;

return (delta) =>
{
// Update phase
phase += delta / 60;
phase %= Math.PI * 2;

// Update ball scales
balls.forEach((b, i) =>
{
const sin = Math.sin((i / ballAmount) * Math.PI - phase);
// Multiply sin with itself to get more steeper edge.

b.scale.set(Math.abs(sin * sin * sin * 0.5) + 0.5);
});
};
}
51 changes: 51 additions & 0 deletions src/examples/v8.0.0/advanced/spinners/spinner3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Container, Graphics, Sprite } from 'pixi.js';

/* ---------------------
Spinner 3. Radial mask.
-------------------- */
export function generateSpinner3(app, position)
{
const container = new Container();

container.position = position;
app.stage.addChild(container);

const base = Sprite.from('https://pixijs.com/assets/bg_scene_rotate.jpg');
const size = 100;

base.width = size;
base.height = size;

const mask = new Graphics();

mask.position.set(size / 2, size / 2);
base.mask = mask;
window.mask = mask;

container.addChild(base);
container.addChild(mask);

let phase = 0;

return (delta) =>
{
// Update phase
phase += delta / 60;
phase %= Math.PI * 2;

const angleStart = 0 - Math.PI / 2;
const angle = phase + angleStart;
const radius = 50;

const x1 = Math.cos(angleStart) * radius;
const y1 = Math.sin(angleStart) * radius;

// Redraw mask
mask.clear()
.moveTo(0, 0)
.lineTo(x1, y1)
.arc(0, 0, radius, angleStart, angle, false)
.lineTo(0, 0)
.fill({ color: 0xff0000 });
};
}
Loading
Loading