Skip to content

Commit 0cdd58e

Browse files
JaimeTorrealbaandretchen0alvarosabunartc
authored
feat: V4 (#420)
* feat(AnimatedSprite): add AnimatedSprite, playground, docs * chore(AnimatedSprite): fix linter errors * chore(AnimatedSprite): update docs * feat(AnimatedSprite): allow [numCols, numRows] as atlas prop * docs(AnimatedSprite): reorder sections, improve clarity * docs(AnimatedSprite): format type names * docs(AnimatedSprite): update no-atlas example to use [cols, rows] * chore(AnimatedSprite): run linter, remove console.log * refactor(AnimatedSprite): create new animation frames if props.reversed is toggled * docs(AtlasAnimationDefinitionParser): change 'delay' to 'duration' * refactor(AtlasAnimationDefinitionParser): make parse function private to module * refactor(AtlasAnimationDefinitionParser): use destructuring * refactor(AtlasAnimationDefinitionParser): use destructuring * refactor(AtlasAnimationDefinitionParser): rename returned value 'result' * chore: run linter * refactor(AtlasAnimationDefinitionParser): rename private error logging functions * refactor(Atlas): rename private functions * fix(Atlas): add missing argument to function call * refactor(AnimatedSprite): merge FrameData types as single type * refactor(AnimatedSprite): change callbacks to emits * chore(AnimatedSprite): run linter * chore(AnimatedSprite): format Atlas error message * fix(AnimatedSprite): return nullFrame animation if requested animation not found * refactor(AnimatedSprite): simplify component onLoop * chore(AnimatedSprite): run lint --fix * refactor(AnimatedSprite): add Atlasish type * refactor(AnimatedSprite): remove onLoad prop * feat(app)!: 227 Change the keyboardcontrols implementation * docs(AnimatedSprite): update docs and demos * docs(AnimatedSprite): update playground demo * refactor(AnimatedSprite): remove TresSprite * refactor(AnimatedSprite): rename prop, anchor -> center * refactor(AnimatedSprite): remove asSprite prop, improve clarity * docs(AnimatedSprite): update docs * refactor(AnimatedSprite): update playground * refactor(AnimatedSprite): rename 'page' -> 'atlas' * refactor(AnimatedSprite): make definitions reactive * feat(AnimatedSprite): change default fps * docs(AnimatedSprite): mark props as 'not reactive' * feat(AnimatedSprite): always emit last frame name on loop and on end * docs(AnimatedSprite): correct and update docs/demos * chore(AnimatedSprite): run linter * docs(AnimatedSprite): improve wording * feat: add arrow keys support * refactor(AnimatedSprite): improve variable name * refactor(AnimatedSprite): use degrees instead of radians in example * chore(AnimatedSprite): fix linter errors * refactor(app)!: 349 Remove directives from cientos * docs(app): 227 Add documentation for new KeyboardControls * feat(app): 227 Final details, ready to go * refactor: move in the right position a piece of code * chore: update core to `v4` * chore: release v4.0.0-next.0 * fix(MeshReflectionMaterial)!: add features/docs, reorganize * feat(AnimatedSprite): add asSprite prop * feat(AnimatedSprite): dispose texture onUnmounted * feat(AnimatedSprite): remove explicit click event * feat(AnimatedSprite): remove unnecessary Suspense * docs(AnimatedSprite): add asSprite control to demo * docs(AnimatedSprite): update demo code line highlights * docs(AnimatedSprite): update atlas path, image names * refactor: defineExpose * refactor: change value.value -> value.instance in defineExpose * fix: uncomment section * refactor(app): 160 Add Global audio, stats, statsGl * refactor: remove extra semi-colon, lint issue * chore: Fix Lint (console.logs should be disabled in playground) * chore: update lint * chore: fix lints * chore: fix demos * chore: fix lint * feat(app): 421 Adapt components to use useLoop instead of useRenderLoop * Revert "feat(app): 421 Adapt components to use useLoop instead of useRenderLoop" This reverts commit 24e9812. * feat(app): 421 Update components to use useLoop instead of useRenderLoop * chore: update statsGl y stats * fix lint * chore: update useEnviroment * chore: update fbo * chore: lint * feat: re-remove tweakpane (#425) * feat(app)!: 313 re-uninstall tweakpane * chore: fix lint * docs: update enviroment and useEnviroment docs * fix: remove hardcoded speed number, that setting at 0 doesn't stop the effect * update lock * chore: add Cylinder to v4 (#439) * chore: add Cylinder to v4 * chore: fix playground link * fix(Lensflare demo): add camera #435 (#441) * feat: update to core v4.2 * chore(ci): update node version to 20 for linting * chore: fix lints * feat: 423 enable on demand render mode usage (#436) * chore(deps): update deps to latest * chore: on demand invalidation composable with prop change detection * feat: on-demand orbit-controls * feat: on-demand camera controls * feat: invalidate also on autoRotate * feat: on-demand map controls and refactor * feat: on-demand transform controls * feat: on-demand keyboard controls * feat: on-demand keybaord controls * chore: added demo suffix to control pages to avoid confusions * feat: on-demand pointer lock controls * feat: on-demand scroll controls * feat: on-demand levioso * feat: correct orbit controls auto rotate invalidation * feat: on-demand text3d * feat: on-demand mouse-parallax * feat: on-demand fbo and size watcher refactor * chore(playground): refactor to use useLoop and sub components * chore: remove unused import for lint fix * chore(playground): refactor lensflare demo to use useLoop * feat: on-demand sampler * feat: on-demand invaldiation on reflector prop change * chore: added render activity graph and try to make on-demand work on AnimatedSprite * chore: renamed positional audio demo * chore: on-demand smoke * feat: on-demand precipitation * feat: on-dermand stars * feat: on-demand Environment * feat: on-demand sky * feat: on-demand Ocean component * chore: testing on-demand on fit * feat: on-demand Wobble Material * feat: on-demand invalidation holographic material * feat: on-demand reflection material * feat: on-demand custom shader material * chore: rename bakeshadows demo * chore: misc route * chore: ci, update action setup * docs: add migration guide from v3 in cientos (to do grammar check, ad… (#428) * docs: add migration guide from v3 in cientos (to do grammar check, add img) * docs: grammar corrections * fix lint * docs: rename migration-guide.md -> migrating-from-v3.md * docs: update wording/formatting --------- Co-authored-by: Peter <[email protected]> * fix(types): fixed types generics for `useGLTF` (#448) * feat(app): Add the option for x and y in mouseparallax component (#444) * feat(app): Add the option for x and y in mouseparallax component * fix reactivity, grammar corrections * change ref for shallowRef * chore: release v4.0.0-next.1 * docs(SVG): set playground render-mode to on-demand * refactor(HolographicMaterial): remove useOnDemandInvalidation, use invalidate * refactor(CustomShaderMaterial): remove useOnDemandInvalidated, use invalidate * refactor(MeshReflectionmaterial): remove useOnDemandInvalidated, use invalidate * refactor: call invalidate on props update * docs: add on-demand shapes playground demo * fix: reimplement ContactShadows for v4 (#449) * chore(deps): update deps to latest * chore: on demand invalidation composable with prop change detection * feat: on-demand orbit-controls * feat: on-demand camera controls * feat: invalidate also on autoRotate * feat: on-demand map controls and refactor * feat: on-demand transform controls * feat: on-demand keyboard controls * feat: on-demand keybaord controls * chore: added demo suffix to control pages to avoid confusions * feat: on-demand pointer lock controls * feat: on-demand scroll controls * feat: on-demand levioso * feat: correct orbit controls auto rotate invalidation * feat: on-demand text3d * feat: on-demand mouse-parallax * feat: on-demand fbo and size watcher refactor * chore(playground): refactor to use useLoop and sub components * chore: remove unused import for lint fix * chore(playground): refactor lensflare demo to use useLoop * feat: on-demand sampler * feat: on-demand invaldiation on reflector prop change * chore: added render activity graph and try to make on-demand work on AnimatedSprite * chore: renamed positional audio demo * chore: on-demand smoke * feat: on-demand precipitation * feat: on-dermand stars * feat: on-demand Environment * feat: on-demand sky * feat: on-demand Ocean component * chore: testing on-demand on fit * feat: on-demand Wobble Material * feat: on-demand invalidation holographic material * feat: on-demand reflection material * feat: on-demand custom shader material * chore: rename bakeshadows demo * chore: misc route * chore: ci, update action setup * chore: update Tres core * fix: reimplement ContactShadows for v4 core * docs: change link name * fix(ContactShadows): add invalidate to updates --------- Co-authored-by: alvarosabu <[email protected]> * feat(Sparkles): invalidate on update (#446) * feat(Sparkles): invalidate on update * chore: fix linter error * refactor(Sparkles): remove renderMode predicate before invalidate * chore: remove on demand composable (#452) * chore: remove `useOnDemandInvalidation` on Levioso * chore: remove composable `useOnDemandInvalidation` * chore: remove composable from Ocean * chore: remove composable on Precipitation * chore: remove composable from sky * chore: remove from Fit * chore: remove from smoke * chore: remove from orbit-controls * chore: remove composable from Text3D * chore: remove from mouse parallax * chore: remove composable from Reflector * chore: only needed fbo invalidation * chore: remove composable from useSurfaceSampler * chore: remove composable from all controls * chore: add invalidation on loop * chore: remove prop speed check on loop for Levioso * chore: remove invalidateOnDemand on MapControls * chore: remove `invalidateOnDemand` from Keyboard controls * chore: add invalidate on fit method, remove watch props * chore: invalidation refactor leftovers * chore(types): fixes some type issues * fix: update to core v4.2.2 to remove warning on invalidation * chore: fix lint * chore: release v4.0.0-rc.0 * feat(fbo): add autoRender flag as an option to useFBO (#458) This PR adds an `autoRender` flag to `FBOOptions`. This flag allows consumers of `useFBO` who want to take control of when and where to render the render target instead of always rendering it with the default scene and camera. Co-authored-by: Alvaro Saburido <[email protected]> * chore: fix lint * chore: release v4.0.0-rc.1 * docs: added recipe for tweakpane to migration guides * chore(playground): added same scale as default * chore: release v4.0.0-rc.2 * chore: linter fix * chore: update deps to fix docs build * fix: typescript issues (#459) * fix: type assertion for props as params of `normalizeVectorFlexibleParam` * fix: type assertion on camera and pointerlock controls * refactor(BlurPass): fix TS errors * refactor(SVG): fix TS errors * refactor(Lensflare): fix TS errors * refactor(Reflector): silence and explain TS error * refactor(HolographicMaterial): add declaration for clock * refactor(MeshWobbleMaterial): fix TS error * fix(useProgress): remove extraneous, unused argument * chore(types): fixed gradient type issue from core * fix(types): controls types * chore(types): fix loaders types * chore(types): HTML * chore(types): improve occlude type on HTML * refactor(environment)!: properly type and return texture ref BREAKING CHANGE: `useEnvironment` now returns a ref with the texture instead of an object { texture } * chore(types): HTML, backdrop and Sparkles type issues * chore(types): correct occlusion types without the refs * fix(transform-controls): fps drops due prop watcher for invalidation * chore: type issues on transform controls --------- Co-authored-by: Peter <[email protected]> * fix: AnimatedSprite (#464) * fix: remove explicit fallthrough attr attachment * fix: remove infinite loop * docs: move click from canvas to object * docs: convert props table to HTML * docs: rephrase * chore: deps update * chore: update deps * ci: update lint action * chore: fix lint * chore: fix lint * chore: lint issues * chore: lint remove whitespaces * chore: lint --------- Co-authored-by: Peter <[email protected]> Co-authored-by: alvarosabu <[email protected]> Co-authored-by: Chau Tran <[email protected]>
1 parent 9e17559 commit 0cdd58e

File tree

170 files changed

+11932
-8309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+11932
-8309
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,20 @@ env:
88
jobs:
99
lint:
1010
name: Lint
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-22.04
1212
strategy:
1313
matrix:
14-
node-version: [18]
14+
node-version: [20]
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4
18-
- name: Setup Pnpm
19-
uses: pnpm/action-setup@v2
20-
with:
21-
version: 8
18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@v4
2220
- name: Use Node.js ${{ matrix.node-version }}
2321
uses: actions/setup-node@v4
2422
with:
2523
node-version: ${{ matrix.node-version }}
26-
cache: 'pnpm'
24+
cache: pnpm
2725
- name: Install dependencies
2826
run: pnpm install
2927
- name: Run Lint

CHANGELOG.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
1+
2+
3+
## [4.0.0-rc.2](https://github.com/Tresjs/cientos/compare/4.0.0-rc.1...4.0.0-rc.2) (2024-07-26)
4+
5+
## [4.0.0-rc.1](https://github.com/Tresjs/cientos/compare/4.0.0-rc.0...4.0.0-rc.1) (2024-07-25)
6+
7+
8+
### Features
9+
10+
* **fbo:** add autoRender flag as an option to useFBO ([#458](https://github.com/Tresjs/cientos/issues/458)) ([ddcd4ac](https://github.com/Tresjs/cientos/commit/ddcd4ac36cfd5b5cbb06e967878a9468b390a17c))
11+
12+
## [4.0.0-rc.0](https://github.com/Tresjs/cientos/compare/4.0.0-next.1...4.0.0-rc.0) (2024-07-24)
13+
14+
15+
### Features
16+
17+
* **Sparkles:** invalidate on update ([#446](https://github.com/Tresjs/cientos/issues/446)) ([cbfd226](https://github.com/Tresjs/cientos/commit/cbfd226b94fb363f3a59a735365c679e8142420f))
18+
19+
20+
### Bug Fixes
21+
22+
* reimplement ContactShadows for v4 ([#449](https://github.com/Tresjs/cientos/issues/449)) ([d71c328](https://github.com/Tresjs/cientos/commit/d71c328969da64beee05088ced05bd7b632d6f31))
23+
* update to core v4.2.2 to remove warning on invalidation ([42afa6e](https://github.com/Tresjs/cientos/commit/42afa6e67962796d2ce076a29917262f9ca09ea5))
24+
25+
## [4.0.0-next.1](https://github.com/Tresjs/cientos/compare/3.9.0...4.0.0-next.1) (2024-07-17)
26+
27+
28+
### ⚠ BREAKING CHANGES
29+
30+
* **MeshReflectionMaterial:** add features/docs, reorganize
31+
32+
### Features
33+
34+
* 423 enable on demand render mode usage ([#436](https://github.com/Tresjs/cientos/issues/436)) ([b3eef40](https://github.com/Tresjs/cientos/commit/b3eef40430d23e2ba6c5a195c0cf510c0bc54ce9))
35+
* **AnimatedSprite:** add asSprite prop ([7a14b55](https://github.com/Tresjs/cientos/commit/7a14b5592d78f57785d04bd1484a35e501b7cceb))
36+
* **AnimatedSprite:** dispose texture onUnmounted ([18d6904](https://github.com/Tresjs/cientos/commit/18d6904570cc34ca9c3e64e6b42ec5c639a6e885))
37+
* **AnimatedSprite:** remove explicit click event ([042c350](https://github.com/Tresjs/cientos/commit/042c350883aec53bdf0331cc4b3378e06d87fb88))
38+
* **AnimatedSprite:** remove unnecessary Suspense ([082d695](https://github.com/Tresjs/cientos/commit/082d695f1a6843a8fa5edcd8e6c32ec8530a03a9))
39+
* **app:** 421 Update components to use useLoop instead of useRenderLoop ([ad3b290](https://github.com/Tresjs/cientos/commit/ad3b290c4afb3adf5bf36ccf02d08ea1beb98bc8))
40+
* **app:** Add the option for x and y in mouseparallax component ([#444](https://github.com/Tresjs/cientos/issues/444)) ([12d5834](https://github.com/Tresjs/cientos/commit/12d5834becba2cdfc26300fd5bf1ec1f9e26afe3))
41+
* re-remove tweakpane ([#425](https://github.com/Tresjs/cientos/issues/425)) ([72284ce](https://github.com/Tresjs/cientos/commit/72284ce2e0e378d353b3573a6216ad6f6dcd4425))
42+
* update to core v4.2 ([14b30f9](https://github.com/Tresjs/cientos/commit/14b30f99282ed3cb1d21cbdf31e672867d79f27c))
43+
44+
45+
### Bug Fixes
46+
47+
* **Lensflare demo:** add camera [#435](https://github.com/Tresjs/cientos/issues/435) ([#441](https://github.com/Tresjs/cientos/issues/441)) ([981de57](https://github.com/Tresjs/cientos/commit/981de572c97183b8d2070925daa8209d2fa6b55e))
48+
* **MeshReflectionMaterial:** add features/docs, reorganize ([58703e3](https://github.com/Tresjs/cientos/commit/58703e362bbe731a56b7ce903160df13513ec18a))
49+
* remove hardcoded speed number, that setting at 0 doesn't stop the effect ([e67f3a2](https://github.com/Tresjs/cientos/commit/e67f3a295025ca1bfb1c0f664ceccefac389e0af))
50+
* **SkyDemo:** value.value -> value ([82fe77b](https://github.com/Tresjs/cientos/commit/82fe77b4dc11fd23b47e40bc33a843dc69cf017f))
51+
* **types:** fixed types generics for `useGLTF` ([#448](https://github.com/Tresjs/cientos/issues/448)) ([62a9bcc](https://github.com/Tresjs/cientos/commit/62a9bcc2d4490c7493667c3316441b5363cb42fc))
52+
* uncomment section ([fac2253](https://github.com/Tresjs/cientos/commit/fac22534818a15d49f631b790185f4f1266c7339))
53+
* vue attrs hyphenation issues ([4f9b61b](https://github.com/Tresjs/cientos/commit/4f9b61b954a916d8f8880798f06c03b79092896b))
54+
55+
## [4.0.0-next.0](https://github.com/Tresjs/cientos/compare/3.9.0...4.0.0-next.1) (2024-03-27)
56+
57+
58+
### ⚠ BREAKING CHANGES
59+
60+
* **app:** 349 Remove directives from cientos
61+
* **app:** 227 Change the keyboardcontrols implementation
62+
63+
### Features
64+
65+
* add arrow keys support ([39e2094](https://github.com/Tresjs/cientos/commit/39e2094338ba37613b189e7d593ecc2b0a35680b))
66+
* **AnimatedSprite:** add AnimatedSprite, playground, docs ([d6ea81b](https://github.com/Tresjs/cientos/commit/d6ea81b5540c2f4bf0f233e269ed98992ee8a551))
67+
* **AnimatedSprite:** allow [numCols, numRows] as atlas prop ([3309d9c](https://github.com/Tresjs/cientos/commit/3309d9c24ee1d006b41bdeaa29eac7c8f9658342))
68+
* **AnimatedSprite:** always emit last frame name on loop and on end ([ed16136](https://github.com/Tresjs/cientos/commit/ed16136a84143396ae8accc327429c1ef1fbdd1b))
69+
* **AnimatedSprite:** change default fps ([44831a4](https://github.com/Tresjs/cientos/commit/44831a492e6a881061b9a113d1a627026b172056))
70+
* **app:** 227 Change the keyboardcontrols implementation ([fed0f86](https://github.com/Tresjs/cientos/commit/fed0f86b3c92aa8ea86be0e6193e1639d421bcc2))
71+
* **app:** 227 Final details, ready to go ([6f06213](https://github.com/Tresjs/cientos/commit/6f06213d92f9b389c3d1fca377002ae0b060c87b))
72+
73+
74+
### Bug Fixes
75+
76+
* **AnimatedSprite:** return nullFrame animation if requested animation not found ([453819e](https://github.com/Tresjs/cientos/commit/453819e0237b58177a34bbeee0af4ce44252195c))
77+
* **Atlas:** add missing argument to function call ([e6b147e](https://github.com/Tresjs/cientos/commit/e6b147e45520238e8fd467863972af8fe8f8ec37))
78+
79+
80+
### Code Refactoring
81+
82+
* **app:** 349 Remove directives from cientos ([8fc4cd5](https://github.com/Tresjs/cientos/commit/8fc4cd582ba85cc09e000627449622e8861ec76a))
83+
184
## [3.9.0](https://github.com/Tresjs/cientos/compare/3.8.0...3.9.0) (2024-05-07)
285

386
### Features
@@ -38,6 +121,22 @@
38121
* transformControls throws error when switching active camera ([f1a477a](https://github.com/Tresjs/cientos/commit/f1a477a46c341f6ed4e58fce1e8999e19feba8d0))
39122
* **type:** correct the east description ([c26da1f](https://github.com/Tresjs/cientos/commit/c26da1f11524f2445a1b0653f35354de4d3b10ed))
40123

124+
## [4.0.0-next.0](https://github.com/Tresjs/cientos/compare/3.8.0...4.0.0-next.0) (2024-03-27)
125+
126+
127+
### Features
128+
129+
* **app:** 252 adding ocean component ([7efb293](https://github.com/Tresjs/cientos/commit/7efb29300a5cda624801316e6bc4f33a88e8de04))
130+
* **app:** 252 Renamed as ocean, add sky support ([473bac6](https://github.com/Tresjs/cientos/commit/473bac61d9831b9334f4ba78b0d4ab979b7b167f))
131+
* **app:** Add RoundedBox component ([8b6cb67](https://github.com/Tresjs/cientos/commit/8b6cb67b686bf242aa6e96c3b68af535ddb944d1))
132+
133+
134+
### Bug Fixes
135+
136+
* **app:** 252 Apply review feedback ([4449208](https://github.com/Tresjs/cientos/commit/4449208fccedca0a37ea2e62142b00188a21e0ad))
137+
* apply feedback ([3a50bc2](https://github.com/Tresjs/cientos/commit/3a50bc29c00dd64775643ab08fe3e5ba569c8248))
138+
* little detail in the interface ([fb6456a](https://github.com/Tresjs/cientos/commit/fb6456a063cc28868fe0178b28695c04ad812ccc))
139+
41140
## [3.8.0](https://github.com/Tresjs/cientos/compare/3.7.0...3.8.0) (2024-02-07)
42141

43142
### Features

docs/.vitepress/config.ts

Lines changed: 110 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
import { defineConfig } from 'vitepress'
22
import { resolve } from 'pathe'
3-
import componentList from '../component-list/components'
43

54
const whitelist = ['TresCanvas', 'TresLeches', 'TresScene']
65

7-
const collapsedSidebarCategories = new Set(['Materials', 'Shapes', 'Misc', 'Directives'])
8-
const sidebar = [
9-
{
10-
text: 'Guide',
11-
items: [{ text: 'Introduction', link: '/guide/' }],
12-
},
13-
...componentList,
14-
].map(
15-
c => collapsedSidebarCategories.has(c.text) ? Object.assign(c, { collapsed: true }) : c,
16-
)
17-
186
// https://vitepress.dev/reference/site-config
197
export default defineConfig({
208
title: 'Cientos',
@@ -65,7 +53,116 @@ export default defineConfig({
6553
{ text: 'Examples', link: 'https://lab.tresjs.org/' },
6654
],
6755

68-
sidebar,
56+
sidebar: [
57+
{
58+
text: 'Guide',
59+
items: [
60+
{ text: 'Introduction', link: '/guide/' },
61+
{ text: 'Migration from v3', link: '/guide/migrating-from-v3' },
62+
],
63+
},
64+
{
65+
text: 'Abstractions',
66+
items: [
67+
{ text: 'Text3D', link: '/guide/abstractions/text-3d' },
68+
{ text: 'Levioso (Float)', link: '/guide/abstractions/levioso' },
69+
{ text: 'useAnimations', link: '/guide/abstractions/use-animations' },
70+
{ text: 'MouseParallax', link: '/guide/abstractions/mouse-parallax' },
71+
{ text: 'Lensflare', link: '/guide/abstractions/lensflare' },
72+
{ text: 'Reflector', link: '/guide/abstractions/reflector' },
73+
{ text: 'GlobalAudio', link: '/guide/abstractions/global-audio' },
74+
{ text: 'Fbo', link: '/guide/abstractions/fbo' },
75+
{ text: 'useFBO', link: '/guide/abstractions/use-fbo' },
76+
{ text: 'useSurfaceSampler', link: '/guide/abstractions/use-surface-sampler' },
77+
{ text: 'Sampler', link: '/guide/abstractions/sampler' },
78+
{ text: 'AnimatedSprite', link: '/guide/abstractions/animated-sprite' },
79+
],
80+
},
81+
{
82+
text: 'Controls',
83+
items: [
84+
{ text: 'OrbitControls', link: '/guide/controls/orbit-controls' },
85+
{ text: 'CameraControls', link: '/guide/controls/camera-controls' },
86+
{ text: 'TransformControls', link: '/guide/controls/transform-controls' },
87+
{ text: 'PointerLockControls', link: '/guide/controls/pointer-lock-controls' },
88+
{ text: 'KeyboardControls', link: '/guide/controls/keyboard-controls' },
89+
{ text: 'ScrollControls', link: '/guide/controls/scroll-controls' },
90+
{ text: 'MapControls', link: '/guide/controls/map-controls' },
91+
],
92+
},
93+
{
94+
text: 'Loaders',
95+
items: [
96+
{ text: 'useProgress', link: '/guide/loaders/use-progress' },
97+
{ text: 'useGLTF', link: '/guide/loaders/use-gltf' },
98+
{ text: 'GLTFModel', link: '/guide/loaders/gltf-model' },
99+
{ text: 'useFBX', link: '/guide/loaders/use-fbx' },
100+
{ text: 'FBXModel', link: '/guide/loaders/fbx-model' },
101+
{ text: 'useVideoTexture', link: '/guide/loaders/use-video-texture' },
102+
{ text: 'SVG', link: '/guide/loaders/svg' },
103+
],
104+
},
105+
{
106+
text: 'Materials',
107+
collapsed: true,
108+
items: [
109+
{ text: 'WobbleMaterial', link: '/guide/materials/wobble-material' },
110+
{ text: 'MeshGlassMaterial', link: '/guide/materials/glass-material' },
111+
{ text: 'CustomShaderMaterial', link: '/guide/materials/custom-shader-material' },
112+
{ text: 'MeshReflectionMaterial', link: '/guide/materials/mesh-reflection-material' },
113+
],
114+
},
115+
{
116+
text: 'Shapes',
117+
collapsed: true,
118+
items: [
119+
{ text: 'Box', link: '/guide/shapes/box' },
120+
{ text: 'CatmullRomCurve3', link: '/guide/shapes/catmullromcurve3' },
121+
{ text: 'Circle', link: '/guide/shapes/circle' },
122+
{ text: 'Cone', link: '/guide/shapes/cone' },
123+
{ text: 'Cylinder', link: '/guide/shapes/cylinder' },
124+
{ text: 'Dodecahedron', link: '/guide/shapes/dodecahedron' },
125+
{ text: 'Icosahedron', link: '/guide/shapes/icosahedron' },
126+
{ text: 'Line2', link: '/guide/shapes/line2' },
127+
{ text: 'Octahedron', link: '/guide/shapes/octahedron' },
128+
{ text: 'Plane', link: '/guide/shapes/plane' },
129+
{ text: 'Ring', link: '/guide/shapes/ring' },
130+
{ text: 'RoundedBox', link: '/guide/shapes/rounded-box' },
131+
{ text: 'Sphere', link: '/guide/shapes/sphere' },
132+
{ text: 'Superformula', link: '/guide/shapes/superformula' },
133+
{ text: 'Tetrahedron', link: '/guide/shapes/tetrahedron' },
134+
{ text: 'Torus', link: '/guide/shapes/torus' },
135+
{ text: 'TorusKnot', link: '/guide/shapes/torus-knot' },
136+
{ text: 'Tube', link: '/guide/shapes/tube' },
137+
],
138+
},
139+
{
140+
text: 'Staging',
141+
items: [
142+
{ text: 'Backdrop', link: '/guide/staging/backdrop' },
143+
{ text: 'Environment', link: '/guide/staging/environment' },
144+
{ text: 'useEnvironment', link: '/guide/staging/use-environment' },
145+
{ text: 'Sky', link: '/guide/staging/sky' },
146+
{ text: 'Stars', link: '/guide/staging/stars' },
147+
{ text: 'Smoke', link: '/guide/staging/smoke' },
148+
{ text: 'ContactShadows', link: '/guide/staging/contact-shadows' },
149+
{ text: 'Precipitation', link: '/guide/staging/precipitation' },
150+
{ text: 'Sparkles', link: '/guide/staging/sparkles' },
151+
{ text: 'Ocean', link: '/guide/staging/ocean' },
152+
],
153+
},
154+
{
155+
text: 'Misc',
156+
collapsed: true,
157+
items: [
158+
{ text: 'Stats', link: '/guide/misc/stats' },
159+
{ text: 'Html', link: '/guide/misc/html-component' },
160+
{ text: 'StatsGl', link: '/guide/misc/stats-gl' },
161+
{ text: 'useGLTFExporter', link: '/guide/misc/use-gltf-exporter' },
162+
{ text: 'BakeShadows', link: '/guide/misc/bake-shadows' },
163+
],
164+
},
165+
],
69166

70167
socialLinks: [
71168
{ icon: 'github', link: 'https://github.com/tresjs/cientos' },
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<script setup lang="ts">
2+
import { TresCanvas } from '@tresjs/core'
3+
import { AnimatedSprite, Box, OrbitControls } from '@tresjs/cientos'
4+
import { TresLeches, useControls } from '@tresjs/leches'
5+
import '@tresjs/leches/styles'
6+
import type { AtlasData } from '../../../../src/core/abstractions/AnimatedSprite/Atlas'
7+
8+
const { centerX, centerY, fps, asSprite } = useControls({
9+
centerX: { value: 0.5, min: 0, max: 1, step: 0.1 },
10+
centerY: { value: 0.5, min: 0, max: 1, step: 0.1 },
11+
fps: { value: 5, min: 0, max: 30, step: 1 },
12+
asSprite: true,
13+
})
14+
15+
const centerDemoAtlas: AtlasData = { frames: [] }
16+
const centerDemoImgData = (() => {
17+
const NUM_ROWS_COLS = 64
18+
const rects: { x: number, y: number, w: number, h: number }[] = []
19+
let h = 0
20+
for (let r = 0; r < NUM_ROWS_COLS; r += h) {
21+
let w = 0
22+
h++
23+
if (r + h >= NUM_ROWS_COLS) {
24+
continue
25+
}
26+
for (let c = 0; c < NUM_ROWS_COLS; c += w) {
27+
w++
28+
if (c + w >= NUM_ROWS_COLS) {
29+
continue
30+
}
31+
rects.push({ x: c, y: r, w, h })
32+
}
33+
}
34+
35+
const canvas = document.createElement('canvas')
36+
const IMG_SIZE = 2048
37+
const COL_SIZE = IMG_SIZE / NUM_ROWS_COLS
38+
const ROW_SIZE = IMG_SIZE / NUM_ROWS_COLS
39+
canvas.width = IMG_SIZE
40+
canvas.height = IMG_SIZE
41+
document.body.append(canvas)
42+
const ctx = canvas.getContext('2d')!
43+
const EDGE_center_SIZE = 6
44+
rects.forEach((rect, i) => {
45+
const frame = { x: rect.x * COL_SIZE, y: rect.y * ROW_SIZE, w: rect.w * COL_SIZE, h: rect.h * ROW_SIZE }
46+
const { x, y, w, h } = frame
47+
centerDemoAtlas.frames.push({ filename: `rect_${i.toString().padStart(4, '0')}`, frame })
48+
ctx.fillStyle = '#222'
49+
ctx.fillRect(x, y, w, h)
50+
51+
ctx.fillStyle = '#999'
52+
ctx.fillRect(
53+
x + w * 0.5 - EDGE_center_SIZE * 0.5,
54+
y + h * 0.5 - EDGE_center_SIZE * 0.5,
55+
EDGE_center_SIZE,
56+
EDGE_center_SIZE,
57+
)
58+
59+
ctx.fillRect(x, y, EDGE_center_SIZE, EDGE_center_SIZE)
60+
ctx.fillRect(x + w * 0.5 - EDGE_center_SIZE * 0.5, y, EDGE_center_SIZE, EDGE_center_SIZE)
61+
ctx.fillRect(x + w - EDGE_center_SIZE, y, EDGE_center_SIZE, EDGE_center_SIZE)
62+
63+
ctx.fillRect(x, y + h * 0.5 - EDGE_center_SIZE * 0.5, EDGE_center_SIZE, EDGE_center_SIZE)
64+
ctx.fillRect(x + w - EDGE_center_SIZE, y + h * 0.5 - EDGE_center_SIZE * 0.5, EDGE_center_SIZE, EDGE_center_SIZE)
65+
66+
ctx.fillRect(x, y + h - EDGE_center_SIZE, EDGE_center_SIZE, EDGE_center_SIZE)
67+
ctx.fillRect(x + w * 0.5 - EDGE_center_SIZE * 0.5, y + h - EDGE_center_SIZE, EDGE_center_SIZE, EDGE_center_SIZE)
68+
ctx.fillRect(x + w - EDGE_center_SIZE, y + h - EDGE_center_SIZE, EDGE_center_SIZE, EDGE_center_SIZE)
69+
})
70+
const imgData = canvas.toDataURL()
71+
canvas.parentElement?.removeChild(canvas)
72+
return imgData
73+
})()
74+
</script>
75+
76+
<template>
77+
<TresLeches style="position:absolute; left:10px; top:10px;" />
78+
<TresCanvas clear-color="#82DBC5">
79+
<TresPerspectiveCamera
80+
:position="[5, 1, 5]"
81+
:look-at="[-2, 0, 0]"
82+
/>
83+
<OrbitControls />
84+
<TresGroup :position-x="2">
85+
<Suspense>
86+
<AnimatedSprite
87+
:image="centerDemoImgData"
88+
:atlas="centerDemoAtlas"
89+
animation="rect"
90+
:center="[centerX.value, centerY.value]"
91+
:fps="fps.value"
92+
:as-sprite="asSprite.value"
93+
>
94+
<TresGroup :scale="0.5">
95+
<Box
96+
:scale="[1, 0.06, 0.06]"
97+
color="red"
98+
/>
99+
<Box
100+
:scale="[0.06, 1, 0.06]"
101+
color="blue"
102+
/>
103+
<Box
104+
:scale="[0.06, 0.06, 1]"
105+
color="green"
106+
/>
107+
</TresGroup>
108+
</AnimatedSprite>
109+
</Suspense>
110+
<TresGridHelper :args="[10, 10]" />
111+
</TresGroup>
112+
</TresCanvas>
113+
</template>

0 commit comments

Comments
 (0)