Skip to content

Commit

Permalink
add alpha support
Browse files Browse the repository at this point in the history
  • Loading branch information
eyezahhhh committed Oct 25, 2022
1 parent dab0287 commit 2ad7c2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Animations from "./animations.js";
backEquipment: "cape",
downsample: 2,
...response,
alpha: true,
// panorama: `https://cosmetica.cc/page/panoramas/${response.panorama}.jpg`,
renderCallback: (scene) => {
if (!scene.player) return;
Expand Down
8 changes: 5 additions & 3 deletions src/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {ShaderPass} from "https://unpkg.com/[email protected]/examples/jsm/postproce
import {FXAAShader} from "https://unpkg.com/[email protected]/examples/jsm/shaders/FXAAShader.js";
import * as ModelUtils from "./ModelUtils.js";

function createRenderer(width, height, antialias) {
function createRenderer(width, height, antialias, alpha) {
// three.js expects a canvas, this fakes it lmfao
const canvas = document.createElement("canvas");

const renderer = new THREE.WebGLRenderer({
canvas,
antialias: antialias,
alpha: alpha,
powerPreference: "high-performance"
});

Expand All @@ -31,8 +32,8 @@ function createRenderer(width, height, antialias) {
return renderer;
}

function drawScene(scene, camera, width, height, imageType, antialias) {
const renderer = createRenderer(width, height, antialias);
function drawScene(scene, camera, width, height, imageType, antialias, alpha) {
const renderer = createRenderer(width, height, antialias, alpha);
renderer.render(scene, camera);
const frameBufferPixels = new Uint8Array(width * height * 4);
const context = renderer.getContext();
Expand Down Expand Up @@ -102,6 +103,7 @@ class Scene {
if (options.canvas) {
this.renderer = new THREE.WebGLRenderer({
canvas: options.canvas,
alpha: options.alpha || false,
powerPreference: "high-performance",
antialias: true
});
Expand Down

0 comments on commit 2ad7c2e

Please sign in to comment.