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

Merge branch 'master' into vanruesc/postprocessing

This commit is contained in:
Kevin Levron 2021-05-02 21:06:50 +02:00
commit 971c8377ec
8 changed files with 21 additions and 13 deletions

View File

@ -12,13 +12,13 @@
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue' import { defineComponent } from 'vue'
import { Box, Camera, LambertMaterial, MeshInterface, PointLight, Renderer, RendererInterface, Scene } from './export' import { Box, Camera, LambertMaterial, MeshPublicInterface, PointLight, Renderer, RendererPublicInterface, Scene } from './export'
export default defineComponent({ export default defineComponent({
components: { Box, Camera, LambertMaterial, PointLight, Renderer, Scene }, components: { Box, Camera, LambertMaterial, PointLight, Renderer, Scene },
mounted() { mounted() {
const renderer = this.$refs.renderer as RendererInterface const renderer = this.$refs.renderer as RendererPublicInterface
const mesh = (this.$refs.box as MeshInterface).mesh const mesh = (this.$refs.box as MeshPublicInterface).mesh
if (renderer && mesh) { if (renderer && mesh) {
renderer.onBeforeRender(() => { renderer.onBeforeRender(() => {
mesh.rotation.x += 0.01 mesh.rotation.x += 0.01

View File

@ -18,6 +18,8 @@ export interface Object3DInterface extends Object3DSetupInterface {
remove(o: Object3D): void remove(o: Object3D): void
} }
export interface Object3DPublicInterface extends ComponentPublicInstance, Object3DInterface {}
// export function object3DSetup(): Object3DSetupInterface { // export function object3DSetup(): Object3DSetupInterface {
// const renderer = inject(RendererInjectionKey) // const renderer = inject(RendererInjectionKey)
// const scene = inject(SceneInjectionKey) // const scene = inject(SceneInjectionKey)

View File

@ -1,7 +1,7 @@
/* eslint-disable no-use-before-define */ /* eslint-disable no-use-before-define */
import { Camera, NoToneMapping, PCFShadowMap, Scene, WebGLRenderer } from 'three' import { Camera, NoToneMapping, PCFShadowMap, 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 { ComponentPublicInstance, defineComponent, InjectionKey, PropType } from 'vue'
import { bindProp } from '../tools' import { bindProp } from '../tools'
import { PointerPublicConfigInterface } from './usePointer' import { PointerPublicConfigInterface } from './usePointer'
import useThree, { SizeInterface, ThreeConfigInterface, ThreeInterface } from './useThree' import useThree, { SizeInterface, ThreeConfigInterface, ThreeInterface } from './useThree'
@ -93,7 +93,9 @@ export interface RendererInterface extends RendererSetupInterface {
removeListener<T extends keyof EventCallbackMap>(t: T, cb: EventCallbackMap[T]): void removeListener<T extends keyof EventCallbackMap>(t: T, cb: EventCallbackMap[T]): void
} }
export const RendererInjectionKey: InjectionKey<RendererInterface> = Symbol('Renderer') export interface RendererPublicInterface extends ComponentPublicInstance, RendererInterface {}
export const RendererInjectionKey: InjectionKey<RendererPublicInterface> = Symbol('Renderer')
export default defineComponent({ export default defineComponent({
name: 'Renderer', name: 'Renderer',

View File

@ -9,5 +9,5 @@ export { default as Raycaster } from './Raycaster'
export { default as CubeCamera } from './CubeCamera' export { default as CubeCamera } from './CubeCamera'
export type { RendererInterface } from './Renderer' export type { RendererPublicInterface } from './Renderer'
export type { Object3DInterface } from './Object3D' export type { Object3DPublicInterface } from './Object3D'

View File

@ -1,4 +1,4 @@
import { defineComponent, InjectionKey, PropType, watch } from 'vue' import { ComponentPublicInstance, defineComponent, InjectionKey, PropType, watch } from 'vue'
import { FrontSide, Material, NormalBlending, Texture } from 'three' import { FrontSide, Material, NormalBlending, Texture } from 'three'
import { MeshInjectionKey, MeshInterface } from '../meshes/Mesh' import { MeshInjectionKey, MeshInterface } from '../meshes/Mesh'
@ -13,7 +13,9 @@ export interface MaterialInterface extends MaterialSetupInterface {
setTexture(texture: Texture | null, key: string): void setTexture(texture: Texture | null, key: string): void
} }
export const MaterialInjectionKey: InjectionKey<MaterialInterface> = Symbol('Material') export interface MaterialPublicInterface extends ComponentPublicInstance, MaterialInterface {}
export const MaterialInjectionKey: InjectionKey<MaterialPublicInterface> = Symbol('Material')
export default defineComponent({ export default defineComponent({
// inject for sub components // inject for sub components

View File

@ -14,4 +14,4 @@ export { default as CubeTexture } from './CubeTexture'
export { default as PointsMaterial } from './PointsMaterial' export { default as PointsMaterial } from './PointsMaterial'
export type { MaterialInterface } from './Material' export type { MaterialPublicInterface } from './Material'

View File

@ -1,4 +1,4 @@
import { ComponentPropsOptions, defineComponent, InjectionKey, watch } from 'vue' import { ComponentPropsOptions, ComponentPublicInstance, defineComponent, InjectionKey, watch } from 'vue'
import { BufferGeometry, Material, Mesh as TMesh } from 'three' import { BufferGeometry, Material, Mesh as TMesh } from 'three'
import Object3D, { Object3DSetupInterface } from '../core/Object3D' import Object3D, { Object3DSetupInterface } from '../core/Object3D'
import { bindProp } from '../tools' import { bindProp } from '../tools'
@ -25,7 +25,9 @@ export interface MeshInterface extends MeshSetupInterface {
setMaterial(m: Material): void setMaterial(m: Material): void
} }
export const MeshInjectionKey: InjectionKey<MeshInterface> = Symbol('Mesh') export interface MeshPublicInterface extends ComponentPublicInstance, MeshInterface {}
export const MeshInjectionKey: InjectionKey<MeshPublicInterface> = Symbol('Mesh')
const Mesh = defineComponent({ const Mesh = defineComponent({
name: 'Mesh', name: 'Mesh',

View File

@ -24,4 +24,4 @@ export { default as Sprite } from './Sprite'
export { default as Points } from './Points' export { default as Points } from './Points'
export type { MeshInterface } from './Mesh' export type { MeshPublicInterface } from './Mesh'