Created
March 13, 2019 14:23
-
-
Save mairin/c68eea77d2b1705eec68d40d540e1e35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```public render( | |
renderer: THREE.WebGLRenderer, | |
scene: THREE.Scene | |
) { | |
this._controls.update(); | |
// for performance | |
// on re-render if something changed (needs to be listening to events from controls to set to true when we want to re-render) | |
if (!this._modified) { | |
return; | |
} | |
// render the "first" layer, i.e. the DICOM | |
renderer.render(scene, this._camera); | |
renderer.clearDepth(); | |
// render another layer | |
// keep reference of the "DICOM" material | |
const dataMaterial = this._stackHelper.slice.mesh.material; | |
// render segmentation | |
this._stackHelper.border.visible = false; | |
this._stackHelper.slice.mesh.material = this._annotationMaterial!; | |
renderer.render(scene, this._camera); | |
// reset material | |
this._stackHelper.slice.mesh.material = dataMaterial; | |
this._modified = false; | |
}``` | |
```this._scene = new THREE.Scene(); | |
this._renderer = new THREE.WebGLRenderer({ | |
antialias: true, | |
alpha: true, | |
preserveDrawingBuffer: true, | |
}); | |
this._renderer.autoClear = false; | |
this._renderer.setClearAlpha(0); | |
this._renderer.setSize(this._containerWidth, this._containerHeight); | |
container.appendChild(this._renderer.domElement);``` | |
```// if you want to optimize rendering loop | |
controls.addEventListener('change', this.markAsModified);``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment