Ver Fonte

feat(cientos): cone abstraction

astanusic há 2 anos atrás
pai
commit
9d04c5456e

+ 29 - 0
packages/cientos/src/core/Cone.vue

@@ -0,0 +1,29 @@
+<script setup lang="ts">
+import { TresColor } from '@tresjs/core/dist/types'
+import { shallowRef } from 'vue'
+
+withDefaults(
+  defineProps<{
+    args?: number[]
+    color?: TresColor
+  }>(),
+  {
+    args: () => [1, 1, 12],
+    color: '0xffffff',
+  },
+)
+
+const coneRef = shallowRef()
+
+defineExpose({
+  value: coneRef,
+})
+</script>
+<template>
+  <TresMesh ref="coneRef" v-bind="$attrs">
+    <TresConeGeometry :args="args" />
+    <slot>
+      <TresMeshBasicMaterial :color="color" />
+    </slot>
+  </TresMesh>
+</template>

+ 2 - 0
packages/cientos/src/index.ts

@@ -11,6 +11,7 @@ import Sphere from './core/Sphere.vue'
 import Torus from './core/Torus.vue'
 import TorusKnot from './core/TorusKnot.vue'
 import Circle from './core/Circle.vue'
+import Cone from './core/Cone.vue'
 
 export * from './core/useGLTF'
 export * from './core/useFBX'
@@ -28,5 +29,6 @@ export {
   Torus,
   TorusKnot,
   Circle,
+  Cone,
   useAnimations,
 }

+ 4 - 1
packages/tres/src/components/Shapes.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import { BasicShadowMap, DoubleSide, NoToneMapping, sRGBEncoding } from 'three'
 import { reactive, shallowRef, watch } from 'vue'
-import { Plane, Box, Sphere, Torus, TorusKnot, Circle, OrbitControls } from '../../../cientos/src/'
+import { Plane, Box, Sphere, Torus, TorusKnot, Circle, Cone, OrbitControls } from '../../../cientos/src/'
 
 const state = reactive({
   clearColor: '#82DBC5',
@@ -60,6 +60,9 @@ watch(circleRef, circle => {
       <Circle ref="circleRef" :args="[0.9, 32]" :position="[0, 6, 2]" :rotation="[Math.PI, 0, 0]" cast-shadow>
         <TresMeshToonMaterial color="lightsalmon" :side="DoubleSide" />
       </Circle>
+      <Cone ref="coneRef" :args="[1, 1, 6]" :position="[2, 6, 2]" :rotation="[Math.PI, 0, 0]" cast-shadow>
+        <TresMeshToonMaterial color="slateblue" :side="DoubleSide" />
+      </Cone>
     </TresScene>
   </TresCanvas>
 </template>