-
-
Notifications
You must be signed in to change notification settings - Fork 143
fix: nodeOps
is now a function
#579
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
Merged
alvarosabu
merged 2 commits into
v4
from
bugfix/560-nodeops-shares-scene-across-multipletrescanvass
Mar 8, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,80 @@ | ||
<script setup lang="ts"></script> | ||
<script setup lang="ts"> | ||
import { TresCanvas, useRenderLoop } from '@tresjs/core' | ||
import { reactive, shallowRef, ref } from 'vue' | ||
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three' | ||
import { OrbitControls } from '@tresjs/cientos' | ||
|
||
const state = reactive({ | ||
clearColor: '#82DBC5', | ||
shadows: true, | ||
alpha: false, | ||
shadowMapType: BasicShadowMap, | ||
outputColorSpace: SRGBColorSpace, | ||
toneMapping: NoToneMapping, | ||
}) | ||
|
||
const { onLoop } = useRenderLoop() | ||
|
||
const boxRef = shallowRef(null) | ||
const showBox = ref(true) | ||
|
||
/* onLoop(({ elapsed }) => { | ||
if (boxRef.value) { | ||
boxRef.value.rotation.y = elapsed | ||
boxRef.value.rotation.z = elapsed | ||
} | ||
}) */ | ||
|
||
setInterval(() => { | ||
showBox.value = !showBox.value | ||
}, 3000) | ||
</script> | ||
|
||
<template> | ||
<Suspense> | ||
<MultipleCanvas /> | ||
</Suspense> | ||
<div class="grid grid-cols-2"> | ||
<div class="aspect-video"> | ||
<TresCanvas clear-color="#fff"> | ||
<TresPerspectiveCamera | ||
:position="[5, 5, 5]" | ||
:look-at="[0, 0, 0]" | ||
/> | ||
|
||
<TresAmbientLight | ||
:intensity="0.5" | ||
color="red" | ||
/> | ||
<TresMesh | ||
v-if="showBox" | ||
ref="boxRef" | ||
:position="[0, 2, 0]" | ||
> | ||
<TresBoxGeometry :args="[1, 1, 1]" /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
<TresDirectionalLight | ||
:position="[0, 2, 4]" | ||
:intensity="1" | ||
cast-shadow | ||
/> | ||
<TresAxesHelper /> | ||
<TresGridHelper :args="[10, 10, 0x444444, 'teal']" /> | ||
</TresCanvas> | ||
</div> | ||
<div class="aspect-video"> | ||
<TresCanvas clear-color="#000"> | ||
<TresPerspectiveCamera | ||
:position="[5, 5, 5]" | ||
:look-at="[0, 0, 0]" | ||
/> | ||
<TresMesh> | ||
<TresSphereGeometry :args="[1, 32, 32]" /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
<TresAmbientLight | ||
:intensity="0.5" | ||
color="red" | ||
/> | ||
</TresCanvas> | ||
</div> | ||
</div> | ||
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ function noop(fn: string): any { | |
fn | ||
} | ||
|
||
let scene: TresScene | null = null | ||
const { logError } = useLogger() | ||
|
||
const supportedPointerEvents = [ | ||
|
@@ -33,8 +32,9 @@ export function invalidateInstance(instance: TresObject) { | |
|
||
} | ||
|
||
export const nodeOps: RendererOptions<TresObject, TresObject | null> = { | ||
createElement(tag, _isSVG, _anchor, props): TresObject | null { | ||
export const nodeOps: () => RendererOptions<TresObject, TresObject | null> = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (non-blocking) Maybe use a verb now, since this is a function? Rename to |
||
let scene: TresScene | null = null | ||
return { createElement(tag, _isSVG, _anchor, props): TresObject | null { | ||
if (!props) props = {} | ||
|
||
if (!props.args) { | ||
|
@@ -303,5 +303,5 @@ export const nodeOps: RendererOptions<TresObject, TresObject | null> = { | |
setScopeId: () => noop('setScopeId'), | ||
cloneNode: () => noop('cloneNode'), | ||
|
||
insertStaticContent: () => noop('insertStaticContent'), | ||
insertStaticContent: () => noop('insertStaticContent') } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Non-blocking)
I think this is a requirement of
nodeOps
, right? (Like, if we created a totally different Vue renderer for something besides THREE, we wouldn't need this at all.)So, can it be close to line 111 or else inside of
nodeOps
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we? If we would create a custom renderer for, dunno, Babylon, it should exist in a completely different package.