Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object3D: Add twoPassTransparentRendering. #25156

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/api/en/core/Object3D.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ <h3>[property:Vector3 scale]</h3>
The object's local scale. Default is [page:Vector3]( 1, 1, 1 ).
</p>

<h3>[property:Boolean twoPassTransparentRendering]</h3>
<p>
Whether or not double-sided, transparent objects should be rendered with two passes or not. Default is `true`.
Mugen87 marked this conversation as resolved.
Show resolved Hide resolved
</p>

<h3>[property:Vector3 up]</h3>
<p>
This is used by the [page:.lookAt lookAt] method, for example, to determine the orientation of the result.<br />
Expand Down
6 changes: 6 additions & 0 deletions docs/api/it/core/Object3D.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ <h3>[property:Vector3 scale]</h3>
La scala locale dell'oggetto. Il valore predefinito è [page:Vector3]( 1, 1, 1 ).
</p>

<h3>[property:Boolean twoPassTransparentRendering]</h3>
<p>
Whether or not double-sided, transparent objects should be rendered with two passes or not. Default is `true`.
</p>


<h3>[property:Vector3 up]</h3>
<p>
Questa proprietà viene utilizzata dal metodo [page:.lookAt lookAt], per esempio, per determinare l'orientamento del risultato.<br />
Expand Down
6 changes: 6 additions & 0 deletions docs/api/ko/core/Object3D.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ <h3>[property:Vector3 scale]</h3>
객체의 로컬 스케일입니다. 기본값은 [page:Vector3]( 1, 1, 1 )입니다.
</p>

<h3>[property:Boolean twoPassTransparentRendering]</h3>
<p>
Whether or not double-sided, transparent objects should be rendered with two passes or not. Default is `true`.
</p>


<h3>[property:Vector3 up]</h3>
<p>
[page:.lookAt lookAt] 메서드에서 사용되며, 결과의 방향을 결정합니다.<br />
Expand Down
6 changes: 6 additions & 0 deletions docs/api/zh/core/Object3D.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ <h3>[property:Vector3 scale]</h3>
物体的局部缩放。默认值是[page:Vector3]( 1, 1, 1 )。
</p>

<h3>[property:Boolean twoPassTransparentRendering]</h3>
<p>
Whether or not double-sided, transparent objects should be rendered with two passes or not. Default is `true`.
</p>


<h3>[property:Vector3 up]</h3>
<p>
这个属性由[page:.lookAt lookAt]方法所使用,例如,来决定结果的朝向。
Expand Down
17 changes: 17 additions & 0 deletions editor/js/Sidebar.Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ function SidebarObject( editor ) {

container.add( objectRenderOrderRow );

// twoPassTransparentRendering

const objectTwoPassTransparentRenderingRow = new UIRow();
const objectTwoPassTransparentRendering = new UICheckbox().onChange( update );

objectTwoPassTransparentRenderingRow.add( new UIText( strings.getKey( 'sidebar/object/twoPassTransparentRendering' ) ).setWidth( '90px' ) );
objectTwoPassTransparentRenderingRow.add( objectTwoPassTransparentRendering );

container.add( objectTwoPassTransparentRenderingRow );

// user data

const objectUserDataRow = new UIRow();
Expand Down Expand Up @@ -533,6 +543,12 @@ function SidebarObject( editor ) {

}

if ( object.twoPassTransparentRendering !== objectTwoPassTransparentRendering.getValue() ) {

editor.execute( new SetValueCommand( editor, object, 'twoPassTransparentRendering', objectTwoPassTransparentRendering.getValue() ) );

}

if ( object.castShadow !== undefined && object.castShadow !== objectCastShadow.getValue() ) {

editor.execute( new SetValueCommand( editor, object, 'castShadow', objectCastShadow.getValue() ) );
Expand Down Expand Up @@ -823,6 +839,7 @@ function SidebarObject( editor ) {
objectVisible.setValue( object.visible );
objectFrustumCulled.setValue( object.frustumCulled );
objectRenderOrder.setValue( object.renderOrder );
objectTwoPassTransparentRendering.setValue( object.twoPassTransparentRendering );

try {

Expand Down
3 changes: 3 additions & 0 deletions editor/js/Strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function Strings( config ) {
'sidebar/object/visible': 'Visible',
'sidebar/object/frustumcull': 'Frustum Cull',
'sidebar/object/renderorder': 'Render Order',
'sidebar/object/twoPassTransparentRendering': 'Two Pass Transparent Rendering',
'sidebar/object/userdata': 'User data',

'sidebar/geometry/type': 'Type',
Expand Down Expand Up @@ -477,6 +478,7 @@ function Strings( config ) {
'sidebar/object/visible': 'Visible',
'sidebar/object/frustumcull': 'Culling',
'sidebar/object/renderorder': 'Ordre de rendus',
'sidebar/object/twoPassTransparentRendering': 'Two Pass Transparent Rendering',
'sidebar/object/userdata': 'Données utilisateur',

'sidebar/geometry/type': 'Type',
Expand Down Expand Up @@ -828,6 +830,7 @@ function Strings( config ) {
'sidebar/object/visible': '可见性',
'sidebar/object/frustumcull': '视锥体裁剪',
'sidebar/object/renderorder': '渲染次序',
'sidebar/object/twoPassTransparentRendering': 'Two Pass Transparent Rendering',
'sidebar/object/userdata': '自定义数据',

'sidebar/geometry/type': '类型',
Expand Down
3 changes: 3 additions & 0 deletions src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Object3D extends EventDispatcher {

this.frustumCulled = true;
this.renderOrder = 0;
this.twoPassTransparentRendering = true;

this.animations = [];

Expand Down Expand Up @@ -691,6 +692,7 @@ class Object3D extends EventDispatcher {
if ( this.visible === false ) object.visible = false;
if ( this.frustumCulled === false ) object.frustumCulled = false;
if ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder;
if ( this.twoPassTransparentRendering === false ) object.twoPassTransparentRendering = this.twoPassTransparentRendering;
if ( Object.keys( this.userData ).length > 0 ) object.userData = this.userData;

object.layers = this.layers.mask;
Expand Down Expand Up @@ -921,6 +923,7 @@ class Object3D extends EventDispatcher {

this.frustumCulled = source.frustumCulled;
this.renderOrder = source.renderOrder;
this.twoPassTransparentRendering = source.twoPassTransparentRendering;

this.userData = JSON.parse( JSON.stringify( source.userData ) );

Expand Down
1 change: 1 addition & 0 deletions src/loaders/ObjectLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ class ObjectLoader extends Loader {
if ( data.visible !== undefined ) object.visible = data.visible;
if ( data.frustumCulled !== undefined ) object.frustumCulled = data.frustumCulled;
if ( data.renderOrder !== undefined ) object.renderOrder = data.renderOrder;
if ( data.twoPassTransparentRendering !== undefined ) object.twoPassTransparentRendering = data.twoPassTransparentRendering;
if ( data.userData !== undefined ) object.userData = data.userData;
if ( data.layers !== undefined ) object.layers.mask = data.layers;

Expand Down
4 changes: 2 additions & 2 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ function WebGLRenderer( parameters = {} ) {

function prepare( material, scene, object ) {

if ( material.transparent === true && material.side === DoubleSide ) {
if ( object.twoPassTransparentRendering === true && ( material.transparent === true && material.side === DoubleSide ) ) {

material.side = BackSide;
material.needsUpdate = true;
Expand Down Expand Up @@ -1310,7 +1310,7 @@ function WebGLRenderer( parameters = {} ) {

material.onBeforeRender( _this, scene, camera, geometry, object, group );

if ( material.transparent === true && material.side === DoubleSide ) {
if ( object.twoPassTransparentRendering === true && ( material.transparent === true && material.side === DoubleSide ) ) {

material.side = BackSide;
material.needsUpdate = true;
Expand Down