Skip to content

Commit 5415d53

Browse files
committed
Updated builds.
1 parent 17f7629 commit 5415d53

10 files changed

Lines changed: 184 additions & 16 deletions

build/three.cjs

Lines changed: 35 additions & 4 deletions
Large diffs are not rendered by default.

build/three.core.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46680,6 +46680,15 @@ class RectAreaLight extends Light {
4668046680
*/
4668146681
this.height = height;
4668246682

46683+
/**
46684+
* A texture that modulates the light color. The texture is
46685+
* projected onto the light's surface and sampled during shading.
46686+
*
46687+
* @type {?Texture}
46688+
* @default null
46689+
*/
46690+
this.map = null;
46691+
4668346692
}
4668446693

4668546694
/**
@@ -46708,6 +46717,7 @@ class RectAreaLight extends Light {
4670846717

4670946718
this.width = source.width;
4671046719
this.height = source.height;
46720+
this.map = source.map;
4671146721

4671246722
return this;
4671346723

@@ -46720,6 +46730,8 @@ class RectAreaLight extends Light {
4672046730
data.object.width = this.width;
4672146731
data.object.height = this.height;
4672246732

46733+
if ( this.map && this.map.isTexture ) data.object.map = this.map.toJSON( meta ).uuid;
46734+
4672346735
return data;
4672446736

4672546737
}

build/three.core.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/three.module.js

Lines changed: 23 additions & 4 deletions
Large diffs are not rendered by default.

build/three.module.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/three.webgpu.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50160,9 +50160,16 @@ class NodeBuilder {
5016050160
*/
5016150161
getSharedContext() {
5016250162

50163-
({ ...this.context });
50163+
const context = { ...this.context };
5016450164

50165-
return this.context;
50165+
delete context.material;
50166+
delete context.getUV;
50167+
delete context.getOutput;
50168+
delete context.getTextureLevel;
50169+
delete context.getAO;
50170+
delete context.getShadow;
50171+
50172+
return context;
5016650173

5016750174
}
5016850175

build/three.webgpu.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/three.webgpu.nodes.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50160,9 +50160,16 @@ class NodeBuilder {
5016050160
*/
5016150161
getSharedContext() {
5016250162

50163-
({ ...this.context });
50163+
const context = { ...this.context };
5016450164

50165-
return this.context;
50165+
delete context.material;
50166+
delete context.getUV;
50167+
delete context.getOutput;
50168+
delete context.getTextureLevel;
50169+
delete context.getAO;
50170+
delete context.getShadow;
50171+
50172+
return context;
5016650173

5016750174
}
5016850175

build/three.webgpu.nodes.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/webgpu_postprocessing_ssgi.html

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,24 @@
3838

3939
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
4040

41+
import { RapierPhysics } from 'three/addons/physics/RapierPhysics.js';
42+
import { RapierHelper } from 'three/addons/helpers/RapierHelper.js';
43+
4144
import { Inspector } from 'three/addons/inspector/Inspector.js';
4245

4346
let camera, scene, renderer, postProcessing, controls;
4447

48+
let physics, position;
49+
50+
let boxes, spheres;
51+
4552
init();
4653

4754
async function init() {
4855

56+
physics = await RapierPhysics();
57+
position = new THREE.Vector3();
58+
4959
camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 0.1, 100 );
5060
camera.position.set( 0, 10, 30 );
5161

@@ -125,6 +135,49 @@
125135
const traaPass = traa( compositePass, scenePassDepth, scenePassVelocity, camera );
126136
postProcessing.outputNode = traaPass;
127137

138+
//
139+
140+
const material = new THREE.MeshStandardMaterial();
141+
142+
const matrix = new THREE.Matrix4();
143+
const color = new THREE.Color();
144+
145+
// Boxes
146+
147+
const geometryBox = new THREE.BoxGeometry( 0.75, 0.75, 0.75 );
148+
boxes = new THREE.InstancedMesh( geometryBox, material, 100 );
149+
boxes.instanceMatrix.setUsage( THREE.DynamicDrawUsage ); // will be updated every frame
150+
boxes.castShadow = true;
151+
boxes.receiveShadow = true;
152+
boxes.userData.physics = { mass: 1, restitution: 1 };
153+
// scene.add( boxes );
154+
155+
for ( let i = 0; i < boxes.count; i ++ ) {
156+
157+
matrix.setPosition( Math.random() - 0.5, Math.random() * 10, Math.random() - 0.5 );
158+
boxes.setMatrixAt( i, matrix );
159+
boxes.setColorAt( i, color.setHex( 0xffffff * Math.random() ) );
160+
161+
}
162+
163+
// Spheres
164+
165+
const geometrySphere = new THREE.IcosahedronGeometry( 0.75, 4 );
166+
spheres = new THREE.InstancedMesh( geometrySphere, material, 100 );
167+
spheres.instanceMatrix.setUsage( THREE.DynamicDrawUsage ); // will be updated every frame
168+
spheres.castShadow = true;
169+
spheres.receiveShadow = true;
170+
spheres.userData.physics = { mass: 1, restitution: 1 };
171+
scene.add( spheres );
172+
173+
for ( let i = 0; i < spheres.count; i ++ ) {
174+
175+
matrix.setPosition( ( Math.random() - 0.5 ) * 10, Math.random() * 2 + 10, ( Math.random() - 0.5 ) * 10 );
176+
spheres.setMatrixAt( i, matrix );
177+
spheres.setColorAt( i, color.setHex( 0xffffff * Math.random() ) );
178+
179+
}
180+
128181
// Cornell Box inspired scene
129182

130183
// Walls
@@ -137,6 +190,7 @@
137190
leftWall.rotation.y = Math.PI * 0.5;
138191
leftWall.position.set( - 10, 7.5, 0 );
139192
leftWall.receiveShadow = true;
193+
leftWall.userData.physics = { mass: 0 };
140194
scene.add( leftWall );
141195

142196
// Right wall - green
@@ -146,6 +200,7 @@
146200
rightWall.rotation.y = Math.PI * - 0.5;
147201
rightWall.position.set( 10, 7.5, 0 );
148202
rightWall.receiveShadow = true;
203+
rightWall.userData.physics = { mass: 0 };
149204
scene.add( rightWall );
150205

151206
// White walls and boxes
@@ -156,6 +211,7 @@
156211
floor.scale.set( 20, 20, 1 );
157212
floor.rotation.x = Math.PI * - .5;
158213
floor.receiveShadow = true;
214+
floor.userData.physics = { mass: 0 };
159215
scene.add( floor );
160216

161217
// Back wall
@@ -164,14 +220,25 @@
164220
backWall.rotation.z = Math.PI * - 0.5;
165221
backWall.position.set( 0, 7.5, - 10 );
166222
backWall.receiveShadow = true;
223+
backWall.userData.physics = { mass: 0 };
167224
scene.add( backWall );
168225

226+
// Front wall
227+
const frontWall = new THREE.Mesh( wallGeometry, whiteMaterial );
228+
frontWall.scale.set( 15, 20, 1 );
229+
frontWall.rotation.z = Math.PI * - 0.5;
230+
frontWall.position.set( 0, 7.5, 10 );
231+
frontWall.visible = false;
232+
frontWall.userData.physics = { mass: 0 };
233+
scene.add( frontWall );
234+
169235
// Ceiling
170236
const ceiling = new THREE.Mesh( wallGeometry, whiteMaterial );
171237
ceiling.scale.set( 20, 20, 1 );
172238
ceiling.rotation.x = Math.PI * 0.5;
173239
ceiling.position.set( 0, 15, 0 );
174240
ceiling.receiveShadow = true;
241+
ceiling.userData.physics = { mass: 0 };
175242
scene.add( ceiling );
176243

177244
// Boxes
@@ -181,6 +248,7 @@
181248
tallBox.position.set( - 3, 3.5, - 2 );
182249
tallBox.castShadow = true;
183250
tallBox.receiveShadow = true;
251+
tallBox.userData.physics = { mass: 1 };
184252
scene.add( tallBox );
185253

186254
const shortBoxGeometry = new THREE.BoxGeometry( 4, 4, 4 );
@@ -189,11 +257,13 @@
189257
shortBox.position.set( 4, 2, 4 );
190258
shortBox.castShadow = true;
191259
shortBox.receiveShadow = true;
260+
shortBox.userData.physics = { mass: 1 };
192261
scene.add( shortBox );
193262

194263
// Light source geometry
195264
const lightSourceGeometry = new THREE.CylinderGeometry( 2.5, 2.5, 1, 64 );
196265
const lightSourceMaterial = new THREE.MeshBasicMaterial();
266+
lightSourceMaterial.color.setScalar( 2 );
197267
const lightSource = new THREE.Mesh( lightSourceGeometry, lightSourceMaterial );
198268
lightSource.position.y = 15;
199269
scene.add( lightSource );
@@ -208,6 +278,28 @@
208278
pointLight.shadow.bias = - 0.0025;
209279
scene.add( pointLight );
210280

281+
physics.addScene( scene );
282+
283+
scene.add( new RapierHelper( physics.world ) );
284+
285+
/*
286+
setInterval( () => {
287+
288+
let index = Math.floor( Math.random() * boxes.count );
289+
290+
position.set( 0, Math.random() * 10 + 1, 0 );
291+
physics.setMeshPosition( boxes, position, index );
292+
293+
//
294+
295+
index = Math.floor( Math.random() * spheres.count );
296+
297+
position.set( 0, Math.random() * 10 + 1, 0 );
298+
physics.setMeshPosition( spheres, position, index );
299+
300+
}, 1000 / 60 );
301+
*/
302+
211303
// Ambient light
212304
const ambientLight = new THREE.AmbientLight( '#0c0c0c' );
213305
scene.add( ambientLight );

0 commit comments

Comments
 (0)