Przeglądaj źródła

feat(cientos) icosahedron abstraction

astanusic 2 lat temu
rodzic
commit
70bbe3dd67

+ 29 - 0
packages/cientos/src/core/Icosahedron.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, 0],
+    color: '0xffffff',
+  },
+)
+
+const icosahedronRef = shallowRef()
+
+defineExpose({
+  value: icosahedronRef,
+})
+</script>
+<template>
+  <TresMesh ref="icosahedronRef" v-bind="$attrs">
+    <TresIcosahedronGeometry :args="args" />
+    <slot>
+      <TresMeshBasicMaterial :color="color" />
+    </slot>
+  </TresMesh>
+</template>

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

@@ -15,6 +15,7 @@ import Cone from './core/Cone.vue'
 import Tube from './core/Tube.vue'
 import Ring from './core/Ring.vue'
 import Tetrahedron from './core/Tetrahedron.vue'
+import Icosahedron from './core/Icosahedron.vue'
 
 export * from './core/useGLTF'
 export * from './core/useFBX'
@@ -36,5 +37,6 @@ export {
   Tube,
   Ring,
   Tetrahedron,
+  Icosahedron,
   useAnimations,
 }

+ 8 - 0
packages/tres/src/components/Shapes.vue

@@ -10,6 +10,7 @@ import {
   Ring,
   TorusKnot,
   Tetrahedron,
+  Icosahedron,
   Circle,
   Cone,
   OrbitControls,
@@ -33,6 +34,7 @@ const circleRef = shallowRef()
 const tubeRef = shallowRef()
 const ringRef = shallowRef()
 const tetrahedronRef = shallowRef()
+const icosahedronRef = shallowRef()
 
 watch(planeRef, plane => {
   console.log('plane', plane.value.position)
@@ -58,6 +60,9 @@ watch(ringRef, ring => {
 watch(tetrahedronRef, tetrahedron => {
   console.log('tetrahedron', tetrahedron.value.position)
 })
+watch(icosahedronRef, icosahedron => {
+  console.log('icosahedron', icosahedron.value.position)
+})
 
 const tubePath = new CubicBezierCurve3(
   new Vector3(-1, 0, 0),
@@ -104,6 +109,9 @@ const tubePath = new CubicBezierCurve3(
       <Tetrahedron ref="tetrahedronRef" :args="[1, 0]" :position="[-2, 6, -2]" cast-shadow>
         <TresMeshToonMaterial color="yellow" />
       </Tetrahedron>
+      <Icosahedron ref="icosahedronRef" :args="[1, 0]" :position="[-4, 6, -2]" cast-shadow>
+        <TresMeshToonMaterial color="red" />
+      </Icosahedron>
     </TresScene>
   </TresCanvas>
 </template>