Kaynağa Gözat

feat(cientos) use fbx gltf components typed props

alvarosabu 2 yıl önce
ebeveyn
işleme
01ec5e8033

+ 3 - 0
packages/cientos/src/core/useEnvironment/const.ts

@@ -5,12 +5,14 @@ export type EnvironmentOptions = {
    * If true, the environment will be set as the scene's background.
    *
    * @type {boolean}
+   * @default false
    */
   background?: boolean
   /**
    * The blur radius of the environment.
    *
    * @type {number}
+   * @default 0
    */
   blur?: number
   /**
@@ -24,6 +26,7 @@ export type EnvironmentOptions = {
    * The path to the files.
    *
    * @type {string}
+   * @default '/'
    */
   path?: string
   /**

+ 12 - 10
packages/cientos/src/core/useFBX/component.ts

@@ -3,17 +3,19 @@ import { defineComponent } from 'vue'
 import { useFBX } from '.'
 import { useCientos } from '../useCientos'
 
-export const FBXModel = defineComponent({
+export interface FBXModelProps {
+  /**
+   * Path to the FBX file.
+   *
+   * @type {string}
+   * @memberof FBXModelProps
+   * @required
+   */
+  path: string
+}
+export const FBXModel = defineComponent<FBXModelProps>({
   name: 'FBXModel',
-  props: {
-    /*
-     * The path to the FBX file.
-     */
-    path: {
-      type: String,
-      required: true,
-    },
-  },
+  props: ['path'] as unknown as undefined,
   async setup(props, { expose }) {
     const { state } = useCientos()
     let model: Object3D | null = null

+ 35 - 18
packages/cientos/src/core/useGLTF/component.ts

@@ -2,25 +2,42 @@ import { defineComponent } from 'vue'
 import { useGLTF } from '.'
 import { useCientos } from '../useCientos'
 
-export const GLTFModel = defineComponent({
+export interface GLTFModelProps {
+  /**
+   *
+   * The path to the GLTF file.
+   *
+   * @type {string}
+   * @required
+   * @memberof GLTFModelProps
+   *
+   **/
+  path: string
+  /**
+   *
+   * Whether to use Draco compression.
+   *
+   * @type {boolean}
+   * @default false
+   * @memberof GLTFModelProps
+   *
+   **/
+  draco?: boolean
+  /**
+   *
+   * The path to the Draco decoder.
+   *
+   * @type {string}
+   * @default 'https://www.gstatic.com/draco/versioned/decoders/1.4.1/'
+   * @memberof GLTFModelProps
+   *
+   **/
+  decoderPath?: string
+}
+
+export const GLTFModel = defineComponent<GLTFModelProps>({
   name: 'GLTFModel',
-  props: {
-    /**
-     * The path to the GLTF file.
-     *
-     */
-    path: String,
-    /**
-     * Whether to use Draco compression.
-     *
-     */
-    draco: Boolean,
-    /**
-     * The path to the Draco decoder.
-     *
-     */
-    decoderPath: String,
-  },
+  props: ['path', 'draco', 'decoderPath'] as unknown as undefined,
 
   async setup(props, { expose }) {
     const { state } = useCientos()