mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
remove three injection
This commit is contained in:
parent
d91ba988ed
commit
3ccf67d7b1
@ -3,7 +3,7 @@ import useCannon from './useCannon.js';
|
||||
// import { bindProp } from '../../tools';
|
||||
|
||||
export default defineComponent({
|
||||
inject: ['three', 'scene', 'renderer'],
|
||||
inject: ['renderer', 'scene'],
|
||||
props: {
|
||||
gravity: { type: Object, default: () => ({ x: 0, y: 0, z: -9.82 }) },
|
||||
broadphase: { type: String },
|
||||
|
@ -16,6 +16,7 @@ export default defineComponent({
|
||||
const renderer = inject('renderer') as RendererInterface
|
||||
return { renderer }
|
||||
},
|
||||
|
||||
render() {
|
||||
return this.$slots.default ? this.$slots.default() : []
|
||||
},
|
||||
|
@ -2,11 +2,9 @@ import { Object3D, Scene } from 'three'
|
||||
import { ComponentPublicInstance, defineComponent, inject, watch } from 'vue'
|
||||
import { bindProp } from '../tools'
|
||||
import { RendererInterface } from './Renderer'
|
||||
import { ThreeInterface } from './useThree'
|
||||
|
||||
export interface Object3DSetupInterface {
|
||||
renderer: RendererInterface
|
||||
three: ThreeInterface
|
||||
scene: Scene
|
||||
o3d?: Object3D
|
||||
parent?: ComponentPublicInstance
|
||||
@ -21,14 +19,13 @@ export interface Object3DInterface extends Object3DSetupInterface {
|
||||
|
||||
export function object3DSetup(): Object3DSetupInterface {
|
||||
const renderer = inject('renderer') as RendererInterface
|
||||
const three = inject('three') as ThreeInterface
|
||||
const scene = inject('scene') as Scene
|
||||
return { three, scene, renderer }
|
||||
return { scene, renderer }
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Object3D',
|
||||
inject: ['renderer', 'three', 'scene'],
|
||||
inject: ['renderer', 'scene'],
|
||||
emits: ['created', 'ready'],
|
||||
props: {
|
||||
position: { type: Object, default: () => ({ x: 0, y: 0, z: 0 }) },
|
||||
|
@ -157,7 +157,6 @@ export default defineComponent({
|
||||
provide() {
|
||||
return {
|
||||
renderer: this,
|
||||
three: this.three,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
@ -23,9 +23,7 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (!this.renderer.scene) {
|
||||
this.renderer.scene = this.scene
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add(o: Object3D) { this.scene.add(o) },
|
||||
|
@ -1,24 +1,21 @@
|
||||
import { Pass } from 'three/examples/jsm/postprocessing/Pass'
|
||||
import { defineComponent, inject } from 'vue'
|
||||
import { RendererInterface } from '../core/Renderer'
|
||||
import { ThreeInterface } from '../core/useThree'
|
||||
import { EffectComposerInterface } from './EffectComposer'
|
||||
|
||||
interface EffectSetupInterface {
|
||||
renderer: RendererInterface
|
||||
three: ThreeInterface
|
||||
composer: EffectComposerInterface
|
||||
pass?: Pass
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
inject: ['renderer', 'three', 'composer'],
|
||||
inject: ['renderer', 'composer'],
|
||||
emits: ['ready'],
|
||||
setup(): EffectSetupInterface {
|
||||
const renderer = inject('renderer') as RendererInterface
|
||||
const three = inject('three') as ThreeInterface
|
||||
const composer = inject('composer') as EffectComposerInterface
|
||||
return { renderer, three, composer }
|
||||
return { renderer, composer }
|
||||
},
|
||||
created() {
|
||||
if (!this.composer) {
|
||||
|
@ -14,7 +14,7 @@ export interface MaterialInterface extends MaterialSetupInterface {
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
inject: ['three', 'mesh'],
|
||||
inject: ['mesh'],
|
||||
props: {
|
||||
color: { type: [String, Number], default: '#ffffff' },
|
||||
depthTest: { type: Boolean, default: true },
|
||||
|
@ -28,7 +28,7 @@ export default defineComponent({
|
||||
this.onPointerDown ||
|
||||
this.onPointerUp ||
|
||||
this.onClick) {
|
||||
this.three.addIntersectObject(this.mesh)
|
||||
this.renderer.three.addIntersectObject(this.mesh)
|
||||
}
|
||||
|
||||
this.initObject3D(this.mesh)
|
||||
|
@ -59,7 +59,7 @@ const Mesh = defineComponent({
|
||||
this.onPointerDown ||
|
||||
this.onPointerUp ||
|
||||
this.onClick) {
|
||||
this.three?.addIntersectObject(mesh)
|
||||
this.renderer.three.addIntersectObject(mesh)
|
||||
}
|
||||
|
||||
this.mesh = mesh
|
||||
|
Loading…
Reference in New Issue
Block a user