Renderer
See Renderer.ts and THREE.WebGLRenderer.
THREE.WebGLRenderer
Props from Name | Description | Type | Default |
---|---|---|---|
alpha | Whether the canvas contains an alpha (transparency) buffer or not. | Boolean | false |
antialias | Whether to perform antialiasing. | Boolean | false |
autoClear | Defines whether the renderer should automatically clear its output before rendering a frame. | Boolean | true |
Custom Props
Name | Description | Type | Default |
---|---|---|---|
orbitCtrl | Enable/disable OrbitControls. If value is an Object, it will be used to configure [OrbitControls](#access-threejs-orbitcontrols). | Boolean, Object | false |
pointer | Listen for pointer events to track mouse or touch positions (2D and 3D). Use renderer.three.pointer to get :
| Boolean, Object | false |
resize | Resize canvas on window resize.
this.$refs.renderer.three.setSize(width, height) | Boolean, String | false |
shadow | Use shadow or not. | Boolean | false |
width | Fixed width | Number | |
height | Fixed height | Number |
Events API (v0.3)
You can use the following functions to add/remove event listeners on Renderer component :
Name | Description | Event |
---|---|---|
onInit | Add init listener | { type: 'init', renderer } |
onMounted | Add mounted listener | { type: 'mounted', renderer } |
onResize | Add resize listener | { type: 'init', renderer, size } |
onBeforeRender | Add beforerender listener | { type: 'beforerender', renderer, time } |
offBeforeRender | Remove beforerender listener | |
onAfterRender | Add afterrender listener | { type: 'afterrender', renderer, time } |
offAfterRender | Remove afterrender listener |
You can also use :
Name | Description |
---|---|
addListener(type, callback) | Add event listener |
removeListener(type, callback) | Remove event listener |
Custom render function
You can use a custom render function :
const renderer = this.$refs.renderer
renderer.onInit(() => {
renderer.renderFn = () => {
// do what you want
}
})
Access ThreeJS renderer
You should set a ref on the renderer :
<Renderer ref="renderer">
...
</Renderer>
You can then access ThreeJS renderer in your component script :
const renderer = this.$ref.renderer.renderer;
Access ThreeJS OrbitControls
In the same fashion you can access the renderer's three
object which contains different functions to control the scene, amongst which is cameraCtrl
, handling the ThreeJS OrbitControls
settings
const orbitCtrl = this.$ref.renderer.three.cameraCtrl;
Events
To use events, apply an event listener in mounted()
section of your App.
orbitCtrl.addEventListener('change', () => {
// Do something when the camera has been transformed by the controls.
})
orbitCtrl.addEventListener('start', () => {
// Do something when an interaction was initiated.
})
orbitCtrl.addEventListener('end', () => {
// Do something when an interaction has finished.
})
Properties, Methods
You can apply all properties and methods in the same way as listed in the official ThreeJS docs
Example:
orbitCtrl.enablePan = false