Skip to content
Merged
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
11 changes: 10 additions & 1 deletion examples/jsm/physics/RapierPhysics.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ function getShape( geometry ) {

// TODO change type to is*

if ( geometry.type === 'BoxGeometry' ) {
if ( geometry.type === 'RoundedBoxGeometry' ) {

const sx = parameters.width !== undefined ? parameters.width / 2 : 0.5;
const sy = parameters.height !== undefined ? parameters.height / 2 : 0.5;
const sz = parameters.depth !== undefined ? parameters.depth / 2 : 0.5;
const radius = parameters.radius !== undefined ? parameters.radius : 0.1;

return RAPIER.ColliderDesc.roundCuboid( sx - radius, sy - radius, sz - radius, radius );

} else if ( geometry.type === 'BoxGeometry' ) {

const sx = parameters.width !== undefined ? parameters.width / 2 : 0.5;
const sy = parameters.height !== undefined ? parameters.height / 2 : 0.5;
Expand Down
9 changes: 8 additions & 1 deletion examples/physics_rapier_basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { RapierPhysics } from 'three/addons/physics/RapierPhysics.js';
import { RapierHelper } from 'three/addons/helpers/RapierHelper.js';
import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
import Stats from 'three/addons/libs/stats.module.js';

let camera, scene, renderer, stats, controls;
Expand Down Expand Up @@ -131,9 +132,15 @@

}

const geometries = [
new THREE.BoxGeometry( 1, 1, 1 ),
new THREE.SphereGeometry( 0.5 ),
new RoundedBoxGeometry( 1, 1, 1, 2, 0.25 )
];

function addBody( ) {

const geometry = ( Math.random() > 0.5 ) ? new THREE.SphereGeometry( 0.5 ) : new THREE.BoxGeometry( 1, 1, 1 );
const geometry = geometries[ Math.floor( Math.random() * geometries.length ) ];
const material = new THREE.MeshStandardMaterial( { color: Math.floor( Math.random() * 0xFFFFFF ) } );

const mesh = new THREE.Mesh( geometry, material );
Expand Down
19 changes: 2 additions & 17 deletions src/renderers/webgpu/utils/WebGPUUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,14 @@ class WebGPUUtils {
/**
* Returns a modified sample count from the given sample count value.
*
* That is required since WebGPU does not support arbitrary sample counts.
* That is required since WebGPU only supports either 1 or 4.
*
* @param {number} sampleCount - The input sample count.
* @return {number} The (potentially updated) output sample count.
*/
getSampleCount( sampleCount ) {

let count = 1;

if ( sampleCount > 1 ) {

// WebGPU only supports power-of-two sample counts and 2 is not a valid value
count = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );

if ( count === 2 ) {

count = 4;

}

}

return count;
return sampleCount >= 4 ? 4 : 1;

}

Expand Down