mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
wip (core)
This commit is contained in:
parent
de98dd8d11
commit
53a5f32344
@ -49,5 +49,8 @@ module.exports = {
|
||||
// }],
|
||||
// 'vue/valid-template-root': 'off',
|
||||
'vue/no-multiple-template-root': 'off',
|
||||
|
||||
'no-empty-function': 'off',
|
||||
'@typescript-eslint/no-empty-function': ['warn'],
|
||||
},
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { defineComponent } from 'vue'
|
||||
// import Object3D from '../core/Object3D';
|
||||
// import Object3D from '../core/Object3D'
|
||||
|
||||
export default defineComponent({
|
||||
// TODO: eventually extend Object3D, for now: error 'injection "scene" not found'
|
||||
|
@ -31,7 +31,7 @@ export default defineComponent({
|
||||
|
||||
// TODO : fix lookat.x
|
||||
if (this.lookAt) this.o3d.lookAt(this.lookAt.x, this.lookAt.y, this.lookAt.z)
|
||||
watch(() => this.lookAt, (v) => { this.o3d.lookAt(v.x, v.y, v.z); }, { deep: true })
|
||||
watch(() => this.lookAt, (v) => { this.o3d.lookAt(v.x, v.y, v.z) }, { deep: true })
|
||||
|
||||
this._parent = this.getParent()
|
||||
if (this.addToParent()) this.$emit('ready', this)
|
||||
|
@ -23,11 +23,12 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
created() {
|
||||
bindProp(this, 'position', this.camera);
|
||||
bindProp(this, 'position', this.camera)
|
||||
|
||||
['left', 'right', 'top', 'bottom', 'near', 'far', 'zoom'].forEach(p => {
|
||||
const watchProps = ['left', 'right', 'top', 'bottom', 'near', 'far', 'zoom']
|
||||
watchProps.forEach(p => {
|
||||
watch(() => this[p], () => {
|
||||
this.camera[p] = this[p];
|
||||
this.camera[p] = this[p]
|
||||
this.camera.updateProjectionMatrix()
|
||||
})
|
||||
})
|
||||
|
@ -18,6 +18,7 @@ export default defineComponent({
|
||||
},
|
||||
setup() {
|
||||
const renderer: null | WebGLRenderer = null
|
||||
const _render: {(): void} = () => {}
|
||||
|
||||
const onMountedCallbacks: {(): void}[] = []
|
||||
const beforeRenderCallbacks: {(): void}[] = []
|
||||
@ -27,6 +28,7 @@ export default defineComponent({
|
||||
three: useThree(),
|
||||
renderer,
|
||||
raf: true,
|
||||
_render,
|
||||
onMountedCallbacks,
|
||||
beforeRenderCallbacks,
|
||||
afterRenderCallbacks,
|
||||
@ -64,7 +66,7 @@ export default defineComponent({
|
||||
} else {
|
||||
requestAnimationFrame(this.renderLoop)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.onMountedCallbacks.forEach(c => c())
|
||||
},
|
||||
|
@ -16,8 +16,8 @@ export interface PointerIntersectEventInterface {
|
||||
intersect?: Intersection
|
||||
}
|
||||
|
||||
export type PointerCallbackType = (e: PointerEventInterface) => void
|
||||
export type PointerIntersectCallbackType = (e: PointerIntersectEventInterface) => void
|
||||
|
||||
export type IntersectObject = Mesh | InstancedMesh
|
||||
|
||||
export interface PointerConfigInterface {
|
||||
@ -29,15 +29,15 @@ export interface PointerConfigInterface {
|
||||
resetOnEnd?: boolean
|
||||
resetPosition?: Vector2
|
||||
resetPositionV3?: Vector3
|
||||
onEnter?(e: PointerEventInterface): void
|
||||
onMove?(e: PointerEventInterface): void
|
||||
onLeave?(e: PointerEventInterface): void
|
||||
onClick?(e: PointerEventInterface): void
|
||||
onIntersectEnter: PointerIntersectCallbackType
|
||||
onIntersectOver: PointerIntersectCallbackType
|
||||
onIntersectMove: PointerIntersectCallbackType
|
||||
onIntersectLeave: PointerIntersectCallbackType
|
||||
onIntersectClick: PointerIntersectCallbackType
|
||||
onEnter?: PointerCallbackType
|
||||
onMove?: PointerCallbackType
|
||||
onLeave?: PointerCallbackType
|
||||
onClick?: PointerCallbackType
|
||||
onIntersectEnter?: PointerIntersectCallbackType
|
||||
onIntersectOver?: PointerIntersectCallbackType
|
||||
onIntersectMove?: PointerIntersectCallbackType
|
||||
onIntersectLeave?: PointerIntersectCallbackType
|
||||
onIntersectClick?: PointerIntersectCallbackType
|
||||
}
|
||||
|
||||
export interface PointerInterface {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Camera, Intersection, Plane, Raycaster, Vector2, Vector3 } from 'three';
|
||||
import { Camera, Intersection, Plane, Raycaster, Vector2, Vector3 } from 'three'
|
||||
import { IntersectObject } from './usePointer'
|
||||
|
||||
export interface RaycasterInterface {
|
||||
|
@ -73,9 +73,9 @@ export default function useThree(): ThreeInterface {
|
||||
// const afterInitCallbacks: void[] = []
|
||||
// let afterResizeCallbacks: void[] = []
|
||||
// let beforeRenderCallbacks: void[] = []
|
||||
const afterInitCallbacks: {(): void;}[] = []
|
||||
let afterResizeCallbacks: {(): void;}[] = []
|
||||
let beforeRenderCallbacks: {(): void;}[] = []
|
||||
const afterInitCallbacks: {(): void}[] = []
|
||||
let afterResizeCallbacks: {(): void}[] = []
|
||||
let beforeRenderCallbacks: {(): void}[] = []
|
||||
|
||||
const intersectObjects: IntersectObject[] = []
|
||||
|
||||
@ -294,7 +294,8 @@ export default function useThree(): ThreeInterface {
|
||||
size.wHeight = oCamera.top - oCamera.bottom
|
||||
} else {
|
||||
const wsize = getCameraSize()
|
||||
size.wWidth = wsize[0]; size.wHeight = wsize[1]
|
||||
size.wWidth = wsize[0]
|
||||
size.wHeight = wsize[1]
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user