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/valid-template-root': 'off',
|
||||||
'vue/no-multiple-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 { defineComponent } from 'vue'
|
||||||
// import Object3D from '../core/Object3D';
|
// import Object3D from '../core/Object3D'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
// TODO: eventually extend Object3D, for now: error 'injection "scene" not found'
|
// TODO: eventually extend Object3D, for now: error 'injection "scene" not found'
|
||||||
|
@ -31,7 +31,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
// TODO : fix lookat.x
|
// TODO : fix lookat.x
|
||||||
if (this.lookAt) this.o3d.lookAt(this.lookAt.x, this.lookAt.y, this.lookAt.z)
|
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()
|
this._parent = this.getParent()
|
||||||
if (this.addToParent()) this.$emit('ready', this)
|
if (this.addToParent()) this.$emit('ready', this)
|
||||||
|
@ -23,11 +23,12 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
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], () => {
|
watch(() => this[p], () => {
|
||||||
this.camera[p] = this[p];
|
this.camera[p] = this[p]
|
||||||
this.camera.updateProjectionMatrix()
|
this.camera.updateProjectionMatrix()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -18,6 +18,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const renderer: null | WebGLRenderer = null
|
const renderer: null | WebGLRenderer = null
|
||||||
|
const _render: {(): void} = () => {}
|
||||||
|
|
||||||
const onMountedCallbacks: {(): void}[] = []
|
const onMountedCallbacks: {(): void}[] = []
|
||||||
const beforeRenderCallbacks: {(): void}[] = []
|
const beforeRenderCallbacks: {(): void}[] = []
|
||||||
@ -27,6 +28,7 @@ export default defineComponent({
|
|||||||
three: useThree(),
|
three: useThree(),
|
||||||
renderer,
|
renderer,
|
||||||
raf: true,
|
raf: true,
|
||||||
|
_render,
|
||||||
onMountedCallbacks,
|
onMountedCallbacks,
|
||||||
beforeRenderCallbacks,
|
beforeRenderCallbacks,
|
||||||
afterRenderCallbacks,
|
afterRenderCallbacks,
|
||||||
@ -64,7 +66,7 @@ export default defineComponent({
|
|||||||
} else {
|
} else {
|
||||||
requestAnimationFrame(this.renderLoop)
|
requestAnimationFrame(this.renderLoop)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
this.onMountedCallbacks.forEach(c => c())
|
this.onMountedCallbacks.forEach(c => c())
|
||||||
},
|
},
|
||||||
|
@ -16,8 +16,8 @@ export interface PointerIntersectEventInterface {
|
|||||||
intersect?: Intersection
|
intersect?: Intersection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 PointerConfigInterface {
|
||||||
@ -29,15 +29,15 @@ export interface PointerConfigInterface {
|
|||||||
resetOnEnd?: boolean
|
resetOnEnd?: boolean
|
||||||
resetPosition?: Vector2
|
resetPosition?: Vector2
|
||||||
resetPositionV3?: Vector3
|
resetPositionV3?: Vector3
|
||||||
onEnter?(e: PointerEventInterface): void
|
onEnter?: PointerCallbackType
|
||||||
onMove?(e: PointerEventInterface): void
|
onMove?: PointerCallbackType
|
||||||
onLeave?(e: PointerEventInterface): void
|
onLeave?: PointerCallbackType
|
||||||
onClick?(e: PointerEventInterface): void
|
onClick?: PointerCallbackType
|
||||||
onIntersectEnter: PointerIntersectCallbackType
|
onIntersectEnter?: PointerIntersectCallbackType
|
||||||
onIntersectOver: PointerIntersectCallbackType
|
onIntersectOver?: PointerIntersectCallbackType
|
||||||
onIntersectMove: PointerIntersectCallbackType
|
onIntersectMove?: PointerIntersectCallbackType
|
||||||
onIntersectLeave: PointerIntersectCallbackType
|
onIntersectLeave?: PointerIntersectCallbackType
|
||||||
onIntersectClick: PointerIntersectCallbackType
|
onIntersectClick?: PointerIntersectCallbackType
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PointerInterface {
|
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'
|
import { IntersectObject } from './usePointer'
|
||||||
|
|
||||||
export interface RaycasterInterface {
|
export interface RaycasterInterface {
|
||||||
|
@ -73,9 +73,9 @@ export default function useThree(): ThreeInterface {
|
|||||||
// const afterInitCallbacks: void[] = []
|
// const afterInitCallbacks: void[] = []
|
||||||
// let afterResizeCallbacks: void[] = []
|
// let afterResizeCallbacks: void[] = []
|
||||||
// let beforeRenderCallbacks: void[] = []
|
// let beforeRenderCallbacks: void[] = []
|
||||||
const afterInitCallbacks: {(): void;}[] = []
|
const afterInitCallbacks: {(): void}[] = []
|
||||||
let afterResizeCallbacks: {(): void;}[] = []
|
let afterResizeCallbacks: {(): void}[] = []
|
||||||
let beforeRenderCallbacks: {(): void;}[] = []
|
let beforeRenderCallbacks: {(): void}[] = []
|
||||||
|
|
||||||
const intersectObjects: IntersectObject[] = []
|
const intersectObjects: IntersectObject[] = []
|
||||||
|
|
||||||
@ -294,7 +294,8 @@ export default function useThree(): ThreeInterface {
|
|||||||
size.wHeight = oCamera.top - oCamera.bottom
|
size.wHeight = oCamera.top - oCamera.bottom
|
||||||
} else {
|
} else {
|
||||||
const wsize = getCameraSize()
|
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