Skip to content

Commit

Permalink
Merge pull request bridge-core#5 from Tim203/feature/alpha-option
Browse files Browse the repository at this point in the history
Added an option to enable a transparent background
  • Loading branch information
ThomasOrs authored Apr 23, 2024
2 parents 697b810 + f8ca311 commit 3123302
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IGeoSchema } from './Schema/Model'
export { Model } from './Model'

export interface IOptions {
alpha?: boolean
antialias?: boolean
width?: number
height?: number
Expand All @@ -39,6 +40,7 @@ export class StandaloneModelViewer {
) {
this.renderer = new WebGLRenderer({
canvas: canvasElement,
alpha: options.alpha ?? false,
antialias: options.antialias ?? false,
})
this.renderer.setPixelRatio(window.devicePixelRatio)
Expand All @@ -51,7 +53,11 @@ export class StandaloneModelViewer {
this.controls = new OrbitControls(this.camera, canvasElement)
this.scene = new Scene()
this.scene.add(new AmbientLight(0xffffff))
this.scene.background = new Color(0xcaf0f8)

if (options.alpha) {
this.scene.background = new Color(0xcaf0f8)
}

this.model = new Model(modelData, texturePath)
this.scene.add(this.model.getGroup())

Expand Down

0 comments on commit 3123302

Please sign in to comment.