Skip to content

Commit

Permalink
Editor: use FullScreenQuad for UITexture (#28273)
Browse files Browse the repository at this point in the history
  • Loading branch information
linbingquan authored May 4, 2024
1 parent e23a51e commit 1784e50
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions editor/js/libs/ui.three.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as THREE from 'three';
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';
import { TGALoader } from 'three/addons/loaders/TGALoader.js';
import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';

import { UISpan, UIDiv, UIRow, UIButton, UICheckbox, UIText, UINumber } from './ui.js';
import { MoveObjectCommand } from '../commands/MoveObjectCommand.js';
Expand Down Expand Up @@ -831,7 +832,7 @@ class UIBoolean extends UISpan {

}

let renderer;
let renderer, fsQuad;

function renderToCanvas( texture ) {

Expand All @@ -841,19 +842,18 @@ function renderToCanvas( texture ) {

}

const image = texture.image;
if ( fsQuad === undefined ) {

renderer.setSize( image.width, image.height, false );
fsQuad = new FullScreenQuad( new THREE.MeshBasicMaterial() );

}

const scene = new THREE.Scene();
const camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
const image = texture.image;

const material = new THREE.MeshBasicMaterial( { map: texture } );
const quad = new THREE.PlaneGeometry( 2, 2 );
const mesh = new THREE.Mesh( quad, material );
scene.add( mesh );
renderer.setSize( image.width, image.height, false );

renderer.render( scene, camera );
fsQuad.material.map = texture;
fsQuad.render( renderer );

return renderer.domElement;

Expand Down

0 comments on commit 1784e50

Please sign in to comment.