Skip to content

Commit

Permalink
fix: proxy app context (#394)
Browse files Browse the repository at this point in the history
* fix: proxy app context

* chore: combine imports

* chore: fix lint

* chore: release v3.2.1-next.0

* fix: object assign approach for inner app context

* chore: release v3.2.1-next.1

* fix: explicitely set app context app

* chore: release v3.2.1-next.2

* fix: revert object assign usage for setting app in appContext

* chore: release v3.2.1-next.3

* Revert "chore: fix lint"

This reverts commit a144712.

* chore: release v3.2.1-next.4
  • Loading branch information
alvarosabu authored Sep 11, 2023
1 parent 924407e commit 2301269
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@


## [3.2.1-next.4](https://github.com/Tresjs/tres/compare/3.2.1-next.3...3.2.1-next.4) (2023-09-11)


### Reverts

* Revert "chore: fix lint" ([f53fba9](https://github.com/Tresjs/tres/commit/f53fba955a0c3f0040ce79f52e1b756147fad4ec))

## [3.2.1-next.3](https://github.com/Tresjs/tres/compare/3.2.1-next.2...3.2.1-next.3) (2023-09-11)


### Bug Fixes

* revert object assign usage for setting app in appContext ([889e022](https://github.com/Tresjs/tres/commit/889e0221ed2e8f2c6a3e4ee91413125c9bfe7281))

## [3.2.1-next.2](https://github.com/Tresjs/tres/compare/3.2.1-next.1...3.2.1-next.2) (2023-09-11)


### Bug Fixes

* explicitely set app context app ([c2a758f](https://github.com/Tresjs/tres/commit/c2a758f4c63641897db7b7065fed8286a699c20e))

## [3.2.1-next.1](https://github.com/Tresjs/tres/compare/3.2.1-next.0...3.2.1-next.1) (2023-09-11)


### Bug Fixes

* object assign approach for inner app context ([3a6dc31](https://github.com/Tresjs/tres/commit/3a6dc317c39cba6b2ebcdcf372eb8ccd6676ef2e))

## [3.2.1-next.0](https://github.com/Tresjs/tres/compare/3.2.0...3.2.1-next.0) (2023-09-11)


### Bug Fixes

* proxy app context ([128e3a5](https://github.com/Tresjs/tres/commit/128e3a5eb7af9c3d9b76f67e4afb19d6d0f550b0))

## [3.2.0](https://github.com/Tresjs/tres/compare/3.1.1...3.2.0) (2023-09-06)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tresjs/core",
"type": "module",
"version": "3.2.0",
"version": "3.2.1-next.4",
"packageManager": "[email protected]",
"description": "Declarative ThreeJS using Vue Components",
"author": "Alvaro Saburido <[email protected]> (https://github.com/alvarosabu/)",
Expand Down
2 changes: 2 additions & 0 deletions playground/src/components/TestSphere.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const pbrTexture = await useTexture({
ambientOcclusion:
'https://raw.githubusercontent.com/Tresjs/assets/main/textures/black-rock/Rock035_2K_AmbientOcclusion.jpg',
})
console.log('sphereRef', getCurrentInstance())
</script>

<template>
Expand Down
10 changes: 8 additions & 2 deletions src/components/TresCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type {
ShadowMapType,
ToneMapping,
} from 'three'
import type { Ref } from 'vue'
import type { Ref,
App } from 'vue'
import {
computed,
onMounted,
Expand All @@ -17,7 +18,8 @@ import {
watchEffect,
Fragment,
defineComponent,
h,
h,
getCurrentInstance,
} from 'vue'
import {
useTresContextProvider,
Expand Down Expand Up @@ -81,9 +83,13 @@ const slots = defineSlots<{
default(): any
}>()
const instance = getCurrentInstance()?.appContext.app
const createInternalComponent = (context: TresContext) =>
defineComponent({
setup() {
const ctx = getCurrentInstance()?.appContext
if (ctx) ctx.app = instance as App
provide('useTres', context)
provide('extend', extend)
return () => h(Fragment, null, slots?.default ? slots.default() : [])
Expand Down

0 comments on commit 2301269

Please sign in to comment.