Giter Site home page Giter Site logo

UseTexture as component about tres HOT 3 OPEN

JaimeTorrealba avatar JaimeTorrealba commented on July 3, 2024
UseTexture as component

from tres.

Comments (3)

andretchen0 avatar andretchen0 commented on July 3, 2024

I think the following is possible with R3F, but not with Tres, atm:

<script setup lang="ts">
const texture = {... load my texture}
</script>

<template>
  <TresMeshStandardMaterial>
    <primitive :object="texture" attach="map" />
  </TresMeshStandardMaterial>
</template>

Would that cover the use case here?

from tres.

JaimeTorrealba avatar JaimeTorrealba commented on July 3, 2024

With the component approach, we don't have to create two components, we can get rid of one layer. Ej

//theExperiences.vue

<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
</script>

<template>
  <TresCanvas >
    ...
   <Suspense>
      <MyComponent />
   </Suspense >
   ...
  </TresCanvas >
</template>

// MyComponent

<script setup lang="ts">
const texture = {... load my texture}
</script>

<template>
   <TresMesh>
     <TresBoxGeometry />
    <TresStandardMaterial :map="map" />
   <TresMesh>
</template>

Obviusly there're many ways to not do this, but we can, abstract one step by just

<TresCanvas >
<Suspense>
   <UseTexture :map="MYMAPTEXTURE" v-slot="{ map }" />
      <TresMeshStandardMaterial :map="map"
   <UseTexture />
</Suspense>
</TresCanvas >

Is just one way to improve DX to our Users

from tres.

andretchen0 avatar andretchen0 commented on July 3, 2024

Ok, I see.

from tres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.