-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e1d771
commit 8b6cb67
Showing
5 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { OrbitControls } from '@tresjs/cientos' | ||
</script> | ||
|
||
<template> | ||
<TresCanvas | ||
window-size | ||
clear-color="#111" | ||
> | ||
<TresPerspectiveCamera | ||
:position="[0, 0, 3]" | ||
:fov="45" | ||
:aspect="1" | ||
:near="0.1" | ||
:far="1000" | ||
/> | ||
<OrbitControls /> | ||
<TresMesh> | ||
<TresBoxGeometry :args="[1, 1, 1]" /> | ||
<TresMeshBasicMaterial :color="0x00ff00" /> | ||
</TresMesh> | ||
<TresDirectionalLight | ||
:position="[0, 2, 4]" | ||
:intensity="2" | ||
/> | ||
<TresAmbientLight /> | ||
</TresCanvas> | ||
</template> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script setup> | ||
import { shallowRef, watch } from 'vue' | ||
import { TresCanvas } from '@tresjs/core' | ||
import { OrbitControls, RoundedBox } from '@tresjs/cientos' | ||
const boxRef = shallowRef() | ||
watch(boxRef, (box) => { | ||
console.log(box) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<TresCanvas | ||
window-size | ||
clear-color="#111" | ||
> | ||
<TresPerspectiveCamera | ||
:position="[0, 0, 7]" | ||
:fov="45" | ||
:aspect="1" | ||
:near="0.1" | ||
:far="1000" | ||
/> | ||
<OrbitControls /> | ||
<RoundedBox ref="boxRef"> | ||
<TresMeshBasicMaterial | ||
:color="0x00ff00" | ||
wireframe | ||
/> | ||
</RoundedBox> | ||
<TresDirectionalLight | ||
:position="[0, 2, 4]" | ||
:intensity="2" | ||
/> | ||
<TresAmbientLight /> | ||
</TresCanvas> | ||
</template> |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script setup lang="ts"> | ||
import { useTresContext } from '@tresjs/core' | ||
import type { TresColor } from '@tresjs/core' | ||
import type { BoxGeometry } from 'three' | ||
import { RoundedBoxGeometry } from 'three-stdlib' | ||
import { shallowRef, toRefs } from 'vue' | ||
export interface BoxProps { | ||
/** | ||
* The width, height and depth, segments, radius. | ||
* @default [1, 1, 1, 2, 0.1] | ||
* @type {number[]} | ||
* @memberof BoxProps | ||
* @see https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/RoundedBoxGeometry.js | ||
* | ||
*/ | ||
args?: ConstructorParameters<typeof BoxGeometry> | ||
/** | ||
* The color of the box. | ||
* @default 0xffffff | ||
* @type {TresColor} | ||
* @memberof BoxProps | ||
* @see https://threejs.org/docs/#api/en/materials/MeshBasicMaterial | ||
*/ | ||
color?: TresColor | ||
} | ||
const props = withDefaults(defineProps<BoxProps>(), { args: () => [1, 1, 1, 2, 0.1], color: '#ffffff' }) | ||
const { args, color } = toRefs(props) | ||
const { extend } = useTresContext() | ||
extend({ RoundedBoxGeometry }) | ||
const roundedBoxRef = shallowRef() | ||
defineExpose({ value: roundedBoxRef }) | ||
</script> | ||
|
||
<template> | ||
<TresMesh ref="roundedBoxRef"> | ||
<TresRoundedBoxGeometry :args="args" /> | ||
<slot> | ||
<TresMeshBasicMaterial :color="color" /> | ||
</slot> | ||
</TresMesh> | ||
</template> |
This file contains 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