فهرست منبع

feat(cientos) dodecahedron abstraction

astanusic 2 سال پیش
والد
کامیت
4f53c5bb05
3فایلهای تغییر یافته به همراه39 افزوده شده و 0 حذف شده
  1. 29 0
      packages/cientos/src/core/Dodecahedron.vue
  2. 2 0
      packages/cientos/src/index.ts
  3. 8 0
      packages/tres/src/components/Shapes.vue

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

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

@@ -17,6 +17,7 @@ import Ring from './core/Ring.vue'
 import Tetrahedron from './core/Tetrahedron.vue'
 import Icosahedron from './core/Icosahedron.vue'
 import Octahedron from './core/Octahedron.vue'
+import Dodecahedron from './core/Dodecahedron.vue'
 
 export * from './core/useGLTF'
 export * from './core/useFBX'
@@ -40,5 +41,6 @@ export {
   Tetrahedron,
   Icosahedron,
   Octahedron,
+  Dodecahedron,
   useAnimations,
 }

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

@@ -12,6 +12,7 @@ import {
   Tetrahedron,
   Icosahedron,
   Octahedron,
+  Dodecahedron,
   Circle,
   Cone,
   OrbitControls,
@@ -37,6 +38,7 @@ const ringRef = shallowRef()
 const tetrahedronRef = shallowRef()
 const icosahedronRef = shallowRef()
 const octahedronRef = shallowRef()
+const dodecahedronRef = shallowRef()
 
 watch(planeRef, plane => {
   console.log('plane', plane.value.position)
@@ -68,6 +70,9 @@ watch(icosahedronRef, icosahedron => {
 watch(octahedronRef, octahedron => {
   console.log('octahedron', octahedron.value.position)
 })
+watch(dodecahedronRef, dodecahedron => {
+  console.log('dodecahedron', dodecahedron.value.position)
+})
 
 const tubePath = new CubicBezierCurve3(
   new Vector3(-1, 0, 0),
@@ -120,6 +125,9 @@ const tubePath = new CubicBezierCurve3(
       <Octahedron ref="octahedronRef" :args="[1, 0]" :position="[-4, 6, 0]" cast-shadow>
         <TresMeshToonMaterial color="greenyellow" />
       </Octahedron>
+      <Dodecahedron ref="dodecahedronRef" :args="[1, 0]" :position="[-4, 6, 2]" cast-shadow>
+        <TresMeshToonMaterial color="deeppink" />
+      </Dodecahedron>
     </TresScene>
   </TresCanvas>
 </template>