mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
improve props types
This commit is contained in:
parent
f50d66b733
commit
0bfac37f53
@ -1,15 +1,16 @@
|
|||||||
import { defineComponent, watch } from 'vue'
|
import { defineComponent, PropType, watch } from 'vue'
|
||||||
import { Vector2 } from 'three'
|
import { Vector2 } from 'three'
|
||||||
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'
|
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'
|
||||||
import EffectPass from './EffectPass'
|
import EffectPass from './EffectPass'
|
||||||
import TiltShift from '../shaders/TiltShift'
|
import TiltShift from '../shaders/TiltShift'
|
||||||
|
import { Vector2PropInterface } from '../core/Object3D'
|
||||||
import { bindProp } from '../tools'
|
import { bindProp } from '../tools'
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
blurRadius: { type: Number, default: 10 },
|
blurRadius: { type: Number, default: 10 },
|
||||||
gradientRadius: { type: Number, default: 100 },
|
gradientRadius: { type: Number, default: 100 },
|
||||||
start: { type: Object, default: () => ({ x: 0, y: 100 }) },
|
start: { type: Object as PropType<Vector2PropInterface>, default: () => ({ x: 0, y: 100 }) },
|
||||||
end: { type: Object, default: () => ({ x: 10, y: 100 }) },
|
end: { type: Object as PropType<Vector2PropInterface>, default: () => ({ x: 10, y: 100 }) },
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TiltShiftPassSetupInterface {
|
interface TiltShiftPassSetupInterface {
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import { defineComponent } from 'vue'
|
import { defineComponent, PropType } from 'vue'
|
||||||
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'
|
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'
|
||||||
import EffectPass from './EffectPass'
|
import EffectPass from './EffectPass'
|
||||||
import ZoomBlur from '../shaders/ZoomBlur'
|
import ZoomBlur from '../shaders/ZoomBlur'
|
||||||
|
import { Vector2PropInterface } from '../core/Object3D'
|
||||||
import { bindProp } from '../tools'
|
import { bindProp } from '../tools'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
extends: EffectPass,
|
extends: EffectPass,
|
||||||
props: {
|
props: {
|
||||||
center: { type: Object, default: () => ({ x: 0.5, y: 0.5 }) },
|
center: { type: Object as PropType<Vector2PropInterface>, default: () => ({ x: 0.5, y: 0.5 }) },
|
||||||
strength: { type: Number, default: 0.5 },
|
strength: { type: Number, default: 0.5 },
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { defineComponent } from 'vue'
|
import { defineComponent, PropType } from 'vue'
|
||||||
import { DirectionalLight } from 'three'
|
import { DirectionalLight } from 'three'
|
||||||
|
import { Vector2PropInterface } from '../core/Object3D'
|
||||||
import Light from './Light'
|
import Light from './Light'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
extends: Light,
|
extends: Light,
|
||||||
props: {
|
props: {
|
||||||
target: { type: Object, default: () => ({ x: 0, y: 0, z: 0 }) },
|
target: { type: Object as PropType<Vector2PropInterface>, default: () => ({ x: 0, y: 0, z: 0 }) },
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.initLight(new DirectionalLight(this.color, this.intensity))
|
this.initLight(new DirectionalLight(this.color, this.intensity))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { DirectionalLight, Light, SpotLight } from 'three'
|
import { DirectionalLight, Light, SpotLight } from 'three'
|
||||||
import { defineComponent, watch } from 'vue'
|
import { defineComponent, PropType, watch } from 'vue'
|
||||||
import Object3D from '../core/Object3D'
|
import Object3D, { Vector2PropInterface } from '../core/Object3D'
|
||||||
import { bindProp, setFromProp } from '../tools'
|
import { bindProp, setFromProp } from '../tools'
|
||||||
|
|
||||||
export interface LightSetupInterface {
|
export interface LightSetupInterface {
|
||||||
@ -14,7 +14,7 @@ export default defineComponent({
|
|||||||
color: { type: String, default: '#ffffff' },
|
color: { type: String, default: '#ffffff' },
|
||||||
intensity: { type: Number, default: 1 },
|
intensity: { type: Number, default: 1 },
|
||||||
castShadow: { type: Boolean, default: false },
|
castShadow: { type: Boolean, default: false },
|
||||||
shadowMapSize: { type: Object, default: () => ({ x: 512, y: 512 }) },
|
shadowMapSize: { type: Object as PropType<Vector2PropInterface>, default: () => ({ x: 512, y: 512 }) },
|
||||||
shadowCamera: { type: Object, default: () => ({}) },
|
shadowCamera: { type: Object, default: () => ({}) },
|
||||||
},
|
},
|
||||||
setup(): LightSetupInterface {
|
setup(): LightSetupInterface {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { defineComponent, watch } from 'vue'
|
import { defineComponent, PropType, watch } from 'vue'
|
||||||
import { MeshStandardMaterial } from 'three'
|
import { MeshStandardMaterial } from 'three'
|
||||||
import { bindProp, bindProps, propsValues } from '../tools'
|
import { bindProp, bindProps, propsValues } from '../tools'
|
||||||
import Material, { wireframeProps } from './Material'
|
import Material, { wireframeProps } from './Material'
|
||||||
|
import { Vector2PropInterface } from '../core/Object3D'
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
aoMapIntensity: { type: Number, default: 1 },
|
aoMapIntensity: { type: Number, default: 1 },
|
||||||
@ -13,7 +14,7 @@ const props = {
|
|||||||
envMapIntensity: { type: Number, default: 1 },
|
envMapIntensity: { type: Number, default: 1 },
|
||||||
lightMapIntensity: { type: Number, default: 1 },
|
lightMapIntensity: { type: Number, default: 1 },
|
||||||
metalness: { type: Number, default: 0 },
|
metalness: { type: Number, default: 0 },
|
||||||
normalScale: { type: Object, default: () => ({ x: 1, y: 1 }) },
|
normalScale: { type: Object as PropType<Vector2PropInterface>, default: () => ({ x: 1, y: 1 }) },
|
||||||
roughness: { type: Number, default: 1 },
|
roughness: { type: Number, default: 1 },
|
||||||
refractionRatio: { type: Number, default: 0.98 },
|
refractionRatio: { type: Number, default: 0.98 },
|
||||||
flatShading: Boolean,
|
flatShading: Boolean,
|
||||||
|
@ -2,6 +2,7 @@ import { defineComponent, PropType, watch } from 'vue'
|
|||||||
import { ClampToEdgeWrapping, LinearFilter, LinearMipmapLinearFilter, ShaderMaterial, Texture, TextureLoader, UVMapping } from 'three'
|
import { ClampToEdgeWrapping, LinearFilter, LinearMipmapLinearFilter, ShaderMaterial, Texture, TextureLoader, UVMapping } from 'three'
|
||||||
import { bindProp } from '../tools'
|
import { bindProp } from '../tools'
|
||||||
import { MaterialInjectionKey, MaterialInterface } from './Material'
|
import { MaterialInjectionKey, MaterialInterface } from './Material'
|
||||||
|
import { Vector2PropInterface } from '../core/Object3D'
|
||||||
|
|
||||||
export interface TexureInterface {
|
export interface TexureInterface {
|
||||||
material?: MaterialInterface
|
material?: MaterialInterface
|
||||||
@ -25,9 +26,9 @@ export default defineComponent({
|
|||||||
wrapT: { type: Number, default: ClampToEdgeWrapping },
|
wrapT: { type: Number, default: ClampToEdgeWrapping },
|
||||||
magFilter: { type: Number, default: LinearFilter },
|
magFilter: { type: Number, default: LinearFilter },
|
||||||
minFilter: { type: Number, default: LinearMipmapLinearFilter },
|
minFilter: { type: Number, default: LinearMipmapLinearFilter },
|
||||||
repeat: { type: Object, default: () => ({ x: 1, y: 1 }) },
|
repeat: { type: Object as PropType<Vector2PropInterface>, default: () => ({ x: 1, y: 1 }) },
|
||||||
rotation: { type: Number, default: 0 },
|
rotation: { type: Number, default: 0 },
|
||||||
center: { type: Object, default: () => ({ x: 0, y: 0 }) },
|
center: { type: Object as PropType<Vector2PropInterface>, default: () => ({ x: 0, y: 0 }) },
|
||||||
},
|
},
|
||||||
setup(): TexureInterface {
|
setup(): TexureInterface {
|
||||||
return {}
|
return {}
|
||||||
|
Loading…
Reference in New Issue
Block a user