|
@@ -1,8 +1,8 @@
|
|
|
-# Instances
|
|
|
+# Instancias
|
|
|
|
|
|
-The core idea of **Tres** is an _autogenerated catalogue_ of all the ThreeJS elements. This catalogue is generated from the ThreeJS source code, so it's always up to date.
|
|
|
+La idea principal de **Tres** es un _catálogo autogenerado_ de todos los elementos de ThreeJS. Este catálogo se genera a partir del código fuente de ThreeJS, por lo que siempre está actualizado.
|
|
|
|
|
|
-When using ThreeJS, you need to import the elements you want to use. For example, if you want to use a `PerspectiveCamera`, you need to import it from the `three` package:
|
|
|
+Cuando usas ThreeJS, necesitas importar los elementos que deseas utilizar. Por ejemplo, si quieres usar una `PerspectiveCamera`, necesitas importarla desde el paquete `three`:
|
|
|
|
|
|
```js
|
|
|
import { PerspectiveCamera } from 'three'
|
|
@@ -10,88 +10,94 @@ import { PerspectiveCamera } from 'three'
|
|
|
const camera = new PerspectiveCamera(45, width / height, 1, 1000)
|
|
|
```
|
|
|
|
|
|
-With **Tres** you don't need to import anything, that's because **Tres** automatically generate a **Vue Component based of the Three Object you want to use in CamelCase with a Tres prefix**. For example, if you want to use a `PerspectiveCamera` you would use `<TresPerspectiveCamera />` component.
|
|
|
+Con **Tres** no necesitas importar nada, esto se debe a que **Tres** genera automáticamente un **Componente Vue basado en el objeto Three que deseas usar en CamelCase con un prefijo Tres**. Por ejemplo, si quieres usar una `PerspectiveCamera`, puedes usar el componente `<TresPerspectiveCamera />`.
|
|
|
|
|
|
```vue
|
|
|
<template>
|
|
|
<TresCanvas>
|
|
|
<TresPerspectiveCamera />
|
|
|
- <!-- Your scene goes here -->
|
|
|
+ <!-- Tu escena vive aqui -->
|
|
|
</TresCanvas>
|
|
|
</template>
|
|
|
```
|
|
|
|
|
|
-This means that you can use the same [documentation](https://threejs.org/docs/) as you would when using plain ThreeJS, but with the power of Vue.
|
|
|
+Esto significa que puedes utilizar la misma [documentación](https://threejs.org/docs/) que usarías al utilizar ThreeJS básico, pero con el poder de Vue.
|
|
|
|
|
|
-## Declaring objects
|
|
|
+## Declarando objetos
|
|
|
|
|
|
-If we follow this argument, you should be able to lay out an instance like this: ❌
|
|
|
+Si seguimos este argumento, deberías poder definir una instancia de esta manera: ❌
|
|
|
|
|
|
```vue
|
|
|
<template>
|
|
|
<TresCanvas>
|
|
|
- <TresPerspectiveCamera visible :position="new THREE.Vector3(1, 2, 3)" />
|
|
|
- <!-- Your scene goes here -->
|
|
|
+ <TresPerspectiveCamera
|
|
|
+ visible
|
|
|
+ :position="new THREE.Vector3(1, 2, 3)"
|
|
|
+ />
|
|
|
+ <!-- Tu escena vive aqui -->
|
|
|
</TresCanvas>
|
|
|
</template>
|
|
|
```
|
|
|
|
|
|
-But with **Tres** this is not needed, you can define properties declaratively like this: ✅
|
|
|
+Pero con **Tres** esto no es necesario, puedes definir las propiedades de forma declarativa de la siguiente manera: ✅
|
|
|
|
|
|
```vue
|
|
|
<template>
|
|
|
<TresCanvas>
|
|
|
- <TresPerspectiveCamera visible :position="[1, 2, 3]" />
|
|
|
- <!-- Your scene goes here -->
|
|
|
+ <TresPerspectiveCamera
|
|
|
+ visible
|
|
|
+ :position="[1, 2, 3]"
|
|
|
+ />
|
|
|
+ <!-- Tu escena vive aqui -->
|
|
|
</TresCanvas>
|
|
|
</template>
|
|
|
```
|
|
|
|
|
|
-## Arguments
|
|
|
+## Argumentos
|
|
|
|
|
|
-Some ThreeJS objects have arguments, for example, the `PerspectiveCamera` constructor has the following arguments:
|
|
|
+Algunos objetos de ThreeJS tienen argumentos, por ejemplo, el constructor `PerspectiveCamera` tiene los siguientes argumentos:
|
|
|
|
|
|
-- `fov` - Camera frustum vertical field of view.
|
|
|
-- `aspect` - Camera frustum aspect ratio.
|
|
|
-- `near` - Camera frustum near plane.
|
|
|
-- `far` - Camera frustum far plane.
|
|
|
+- `fov` - Campo de visión vertical de la cámara.
|
|
|
+- `aspect` - Relación de aspecto del frustum de la cámara.
|
|
|
+- `near` - Plano cercano del frustum de la cámara.
|
|
|
+- `far` - Plano lejano del frustum de la cámara.
|
|
|
|
|
|
-To pass these arguments to the `TresPerspectiveCamera` component, you can use the `args` prop:
|
|
|
+Para pasar estos argumentos al componente `TresPerspectiveCamera`, puedes usar la propiedad `args`:
|
|
|
|
|
|
```vue
|
|
|
<template>
|
|
|
<TresCanvas>
|
|
|
<TresPerspectiveCamera :args="[45, 1, 0.1, 1000]" />
|
|
|
- <!-- Your scene goes here -->
|
|
|
+ <!-- Tu escena vive aqui -->
|
|
|
</TresCanvas>
|
|
|
</template>
|
|
|
```
|
|
|
|
|
|
-This is the same as doing this:
|
|
|
+Esto es lo mismo que hacer esto:
|
|
|
|
|
|
```ts
|
|
|
const camera = new PerspectiveCamera(45, 1, 0.1, 1000)
|
|
|
```
|
|
|
|
|
|
-## Props
|
|
|
+## Propiedades
|
|
|
|
|
|
-You can also pass props to the component, for example, the `TresAmbientLight` has a `intensity` property, so you can pass it to the component like this:
|
|
|
+También puedes pasar propiedades al componente, por ejemplo, el `TresAmbientLight` tiene una propiedad `intensity`, por lo que puedes pasarla al componente de la siguiente manera:
|
|
|
|
|
|
```html
|
|
|
<TresAmbientLight :intensity="0.5" />
|
|
|
```
|
|
|
|
|
|
-### Set
|
|
|
+### Establecer
|
|
|
|
|
|
-All properties whose underlying object has a `.set()` method have a shortcut to receive the value as an array. For example, the `TresPerspectiveCamera` has a `position` property, which is a `Vector3` object, so you can pass it to the component like this:
|
|
|
+Todas las propiedades cuyo objeto subyacente tiene un método `.set()` tienen un atajo para recibir el valor como un array. Por ejemplo, el `TresPerspectiveCamera` tiene una propiedad `position`, que es un objeto `Vector3`, por lo que puedes pasarlo al componente de esta manera:
|
|
|
|
|
|
```html
|
|
|
<TresPerspectiveCamera :position="[1, 2, 3]" />
|
|
|
```
|
|
|
|
|
|
-To specify transformation properties such as position, rotation, and scale, a shorthand is available that allows you to directly indicate the axis you wish to set within the props. A similar shorthand is also available for color property.
|
|
|
+Para especificar propiedades de transformación como posición, rotación y escala, hay una forma abreviada disponible que te permite indicar directamente el eje que deseas establecer dentro de las propiedades. Una forma abreviada similar también está disponible para la propiedad de color.
|
|
|
|
|
|
-<!-- I changed color syntax from vue to html, because vue seems broken and does not color nested components -->
|
|
|
+<!-- Cambié la sintaxis de color de Vue a HTML, porque Vue parece estar roto y no colorea los componentes anidados -->
|
|
|
```html
|
|
|
<TresMesh :position-x="1" :scale-y="2" :rotation-x="Math.PI * 2">
|
|
|
<TresMeshBasicMaterial :color-r="0.7" :color-b="0.3" />
|
|
@@ -99,8 +105,8 @@ To specify transformation properties such as position, rotation, and scale, a sh
|
|
|
```
|
|
|
|
|
|
::: warning
|
|
|
-When you set the rotation property in [three.js](https://threejs.org/docs/index.html#api/en/math/Euler), it will use the 'XYZ' order by default.
|
|
|
-It is important to note that when setting the rotation property with the shorthand, the order in which you set the angles matters. For more information on this topic, please refer to [Euler angles](https://en.wikipedia.org/wiki/Euler_angles)
|
|
|
+Cuando estableces la propiedad de rotación en [three.js](https://threejs.org/docs/index.html#api/en/math/Euler), se utilizará el orden 'XYZ' de forma predeterminada.
|
|
|
+Es importante tener en cuenta que al establecer la propiedad de rotación con la forma abreviada, el orden en el que estableces los ángulos importa. Para obtener más información sobre este tema, consulta [Ángulos de Euler](https://es.wikipedia.org/wiki/%C3%81ngulos_de_Euler)
|
|
|
:::
|
|
|
|
|
|
```vue
|
|
@@ -108,12 +114,12 @@ It is important to note that when setting the rotation property with the shortha
|
|
|
|
|
|
<TresMesh :rotation-z="Math.PI * 2" :rotation-x="1" :rotation-y="2" />
|
|
|
|
|
|
-<!-- Note that the order of the rotation properties matters, and swapping the order can result in different outcomes. -->
|
|
|
+<!-- Ten en cuenta que el orden de las propiedades de rotación importa y cambiar el orden puede dar lugar a resultados diferentes. -->
|
|
|
```
|
|
|
|
|
|
-### Scalar
|
|
|
+### Escalar
|
|
|
|
|
|
-Another shortcut you can use is pass a scalar value to a property that expects a `Vector3` object, using the same value for the rest of the Vector:
|
|
|
+Otro atajo que puedes usar es pasar un valor escalar a una propiedad que espera un objeto `Vector3`, usando el mismo valor para el resto del vector:
|
|
|
|
|
|
```html
|
|
|
<TresPerspectiveCamera :position="5" /> ✅
|
|
@@ -123,9 +129,9 @@ Another shortcut you can use is pass a scalar value to a property that expects a
|
|
|
<TresPerspectiveCamera :position="[5, 5, 5]" /> ✅
|
|
|
```
|
|
|
|
|
|
-### Colors
|
|
|
+### Colores
|
|
|
|
|
|
-You can pass colors to the components using the `color` prop, which accepts a string with the color name or a hex value:
|
|
|
+Puedes pasar colores a los componentes usando la propiedad `color`, la cual acepta un string con el nombre del color o un valor hexadecimal:
|
|
|
|
|
|
```html
|
|
|
<TresAmbientLight color="teal" /> ✅
|
|
@@ -135,9 +141,9 @@ You can pass colors to the components using the `color` prop, which accepts a st
|
|
|
<TresAmbientLight color="#008080" /> ✅
|
|
|
```
|
|
|
|
|
|
-### Methods
|
|
|
+### Métodos
|
|
|
|
|
|
-Some underlying properties are actually methods, the `TresPerspectiveCamera` has a `lookAt` method inherit from [Object3d](https://threejs.org/docs/#api/en/core/Object3D.lookAt), so you can pass it the coords to the component like this:
|
|
|
+Algunas propiedades subyacentes son en realidad métodos, el `TresPerspectiveCamera` tiene un método `lookAt` heredado de [Object3d](https://threejs.org/docs/#api/en/core/Object3D.lookAt), por lo que puedes pasarle las coordenadas al componente de esta manera:
|
|
|
|
|
|
```html
|
|
|
<TresPerspectiveCamera :look-at="[1, 2, 3]" />
|