Skip to content

Commit 8c94f09

Browse files
committed
move textured-sprites-from-tileset-r3f example to lookbook
1 parent 19a98a7 commit 8c94f09

File tree

10 files changed

+74
-73
lines changed

10 files changed

+74
-73
lines changed
Loading

examples/r3f/src/textured-sprites-from-tileset/textured-sprites-from-tileset.jsx renamed to apps/lookbook/src/components/demos/textured-sprites-from-tileset-r3f/DemoOrDie.jsx

+15-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Effects } from "@react-three/drei";
2-
import { extend } from "@react-three/fiber";
1+
import {Effects} from '@react-three/drei';
2+
import {extend} from '@react-three/fiber';
33
import {
44
forwardRefValue,
55
GetStage2D,
@@ -12,19 +12,22 @@ import {
1212
TileSet,
1313
useFrameLoop,
1414
useTextureAtlas,
15-
} from "twopoint5d-r3f";
16-
import { useRef } from "react";
17-
import { FilmPass } from "three/examples/jsm/postprocessing/FilmPass";
18-
import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass";
15+
} from '@spearwolf/twopoint5d-r3f';
16+
import {useRef} from 'react';
1917

20-
import { BouncingSprites } from "../textured-sprites/BouncingSprites";
18+
import {FilmPass} from 'three/examples/jsm/postprocessing/FilmPass';
19+
import {RenderPass} from 'three/examples/jsm/postprocessing/RenderPass';
2120

22-
extend({ RenderPass, FilmPass });
21+
import assetsUrl from '~demos/utils/assetsUrl.ts';
2322

24-
export const DemoOrDie = ({ capacity }) => {
23+
import {BouncingSprites} from '../textured-sprites-r3f/BouncingSprites.js';
24+
25+
extend({RenderPass, FilmPass});
26+
27+
export const DemoOrDie = ({capacity}) => {
2528
const geometry = useRef();
2629

27-
const atlas = useTextureAtlas("tiles");
30+
const atlas = useTextureAtlas('tiles');
2831

2932
useFrameLoop(() => new BouncingSprites(150, 75, 5), {
3033
geometry: forwardRefValue(geometry),
@@ -34,22 +37,13 @@ export const DemoOrDie = ({ capacity }) => {
3437

3538
return (
3639
<>
37-
<TileSet
38-
name="tiles"
39-
url="/examples/assets/nobinger-anim-sheet.png"
40-
tileWidth={64}
41-
tileHeight={64}
42-
margin={1}
43-
/>
40+
<TileSet name="tiles" url={assetsUrl('nobinger-anim-sheet.png')} tileWidth={64} tileHeight={64} margin={1} />
4441

4542
<Stage2D name="stage1" noAutoRender defaultCamera>
4643
<ParallaxProjection plane="xy" origin="bottom left" pixelZoom={4} />
4744

4845
<TexturedSprites>
49-
<TexturedSpritesGeometry
50-
capacity={capacity}
51-
ref={geometry}
52-
></TexturedSpritesGeometry>
46+
<TexturedSpritesGeometry capacity={capacity} ref={geometry}></TexturedSpritesGeometry>
5347
<TexturedSpritesMaterial depthTest={false} depthWrite={false}>
5448
<TextureRef name="tiles" attach="colorMap" />
5549
</TexturedSpritesMaterial>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {OrbitControls} from '@react-three/drei';
2+
import {Canvas} from '@react-three/fiber';
3+
import {StrictMode} from 'react';
4+
import {DemoOrDie} from './DemoOrDie.jsx';
5+
6+
export default function main() {
7+
return (
8+
<Canvas linear flat dpr={[1, 2]} camera={{position: [0, 0, 50]}}>
9+
<StrictMode>
10+
<DemoOrDie capacity={500} />
11+
<OrbitControls />
12+
</StrictMode>
13+
</Canvas>
14+
);
15+
}

apps/lookbook/src/pages/demos/_animated-billboards.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"title": "animated billboards",
3-
"description": "A demo showing animated billboards in 3d",
3+
"description": "Animated billboards dancing in a 3D environment",
44
"url": "/demos/animated-billboards",
55
"tags": [
66
"AnimatedSprites",

apps/lookbook/src/pages/demos/_animated-sprites.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"title": "animated sprites",
3-
"description": "A demo showing 2d sprites in 3d with frame based animations",
3+
"description": "Textured sprites with frame based animations",
44
"url": "/demos/animated-sprites",
55
"tags": [
66
"AnimatedSprites",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"title": "textured sprites from tileset (r3f)",
3+
"description": "Render textured sprites from tileset image",
4+
"url": "/demos/textured-sprites-from-tileset-r3f",
5+
"tags": [
6+
"<GetStage2D/>",
7+
"<ParallaxProjection/>",
8+
"<Stage2D/>",
9+
"<TexturedSprites/>",
10+
"<TexturedSpritesGeometry/>",
11+
"<TexturedSpritesMaterial/>",
12+
"<TextureRef/>",
13+
"<TileSet/>",
14+
"useFrameLoop",
15+
"useTextureAtlas",
16+
"tilesets",
17+
"textures",
18+
"react",
19+
"r3f"
20+
],
21+
"previewImage": "textured-sprites-from-tileset-r3f.png"
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
import DemoOrDie from '~components/demos/textured-sprites-from-tileset-r3f/index.jsx';
3+
import Layout from '~layouts/ReactDemo.astro';
4+
import {title} from './_textured-sprites-from-tileset-r3f.json';
5+
---
6+
7+
<Layout title={title}>
8+
<DemoOrDie client:only />
9+
</Layout>
10+
11+
<style>
12+
body {
13+
margin: 0;
14+
height: 100vh;
15+
overflow-y: hidden;
16+
background-color: rgb(100, 118, 136);
17+
background: radial-gradient(circle, rgb(231, 231, 231) 0%, rgb(107, 122, 107) 100%);
18+
color: #eee;
19+
}
20+
</style>

examples/r3f/public/textured-sprites-from-tileset.html

-22
This file was deleted.

examples/r3f/src/textured-sprites-from-tileset/index.jsx

-16
This file was deleted.

examples/r3f/src/utils/LogStageSizeToConsole.jsx

-12
This file was deleted.

0 commit comments

Comments
 (0)