1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

pointer config prop ts

This commit is contained in:
Kevin Levron 2021-04-26 18:37:45 +02:00
parent 5562d5f496
commit f50d66b733
3 changed files with 13 additions and 9 deletions

View File

@ -2,6 +2,7 @@
import { Camera, Scene, WebGLRenderer } from 'three' import { Camera, Scene, WebGLRenderer } from 'three'
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer' import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer'
import { defineComponent, InjectionKey, PropType } from 'vue' import { defineComponent, InjectionKey, PropType } from 'vue'
import { PointerPublicConfigInterface } from './usePointer'
import useThree, { SizeInterface, ThreeConfigInterface, ThreeInterface } from './useThree' import useThree, { SizeInterface, ThreeConfigInterface, ThreeInterface } from './useThree'
type CallbackType<T> = (event: T) => void type CallbackType<T> = (event: T) => void
@ -94,9 +95,9 @@ export default defineComponent({
antialias: Boolean, antialias: Boolean,
alpha: Boolean, alpha: Boolean,
autoClear: { type: Boolean, default: true }, autoClear: { type: Boolean, default: true },
orbitCtrl: { type: [Boolean, Object], default: false }, orbitCtrl: { type: [Boolean, Object] as PropType<boolean | Record<string, unknown>>, default: false },
pointer: { type: [Boolean, Object], default: false }, pointer: { type: [Boolean, Object] as PropType<boolean | PointerPublicConfigInterface>, default: false },
resize: { type: [Boolean, String], default: false }, resize: { type: [Boolean, String] as PropType<boolean | string>, default: false },
shadow: Boolean, shadow: Boolean,
width: String, width: String,
height: String, height: String,

View File

@ -20,10 +20,7 @@ export type PointerCallbackType = (e: PointerEventInterface) => void
export type PointerIntersectCallbackType = (e: PointerIntersectEventInterface) => void export type PointerIntersectCallbackType = (e: PointerIntersectEventInterface) => void
export type IntersectObject = Mesh | InstancedMesh export type IntersectObject = Mesh | InstancedMesh
export interface PointerConfigInterface { export interface PointerPublicConfigInterface {
camera: Camera
domElement: HTMLCanvasElement
intersectObjects: IntersectObject[]
intersectMode?: 'frame' intersectMode?: 'frame'
touch?: boolean touch?: boolean
resetOnEnd?: boolean resetOnEnd?: boolean
@ -40,6 +37,12 @@ export interface PointerConfigInterface {
onIntersectClick?: PointerIntersectCallbackType onIntersectClick?: PointerIntersectCallbackType
} }
export interface PointerConfigInterface extends PointerPublicConfigInterface {
camera: Camera
domElement: HTMLCanvasElement
intersectObjects: IntersectObject[]
}
export interface PointerInterface { export interface PointerInterface {
position: Vector2 position: Vector2
positionN: Vector2 positionN: Vector2

View File

@ -1,7 +1,7 @@
import { Camera, OrthographicCamera, PerspectiveCamera, Scene, WebGLRenderer } from 'three' import { Camera, OrthographicCamera, PerspectiveCamera, Scene, WebGLRenderer } from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js' import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js' import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js'
import usePointer, { IntersectObject, PointerConfigInterface, PointerInterface } from './usePointer' import usePointer, { IntersectObject, PointerConfigInterface, PointerPublicConfigInterface, PointerInterface } from './usePointer'
export interface SizeInterface { export interface SizeInterface {
width: number width: number
@ -17,7 +17,7 @@ export interface ThreeConfigInterface {
alpha: boolean alpha: boolean
autoClear: boolean autoClear: boolean
orbitCtrl: boolean | Record<string, unknown> orbitCtrl: boolean | Record<string, unknown>
pointer: boolean | PointerConfigInterface pointer: boolean | PointerPublicConfigInterface
resize: boolean | string resize: boolean | string
width?: number width?: number
height?: number height?: number