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

Add physics_ammo_instancing test #525

Merged
merged 4 commits into from
Jul 4, 2023
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
5 changes: 3 additions & 2 deletions examples-testing/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Update patch

- `npm run create-examples`
- Commit changes
- `git apply changes.patch`
- Make changes
- `yarn run type-check`
Expand All @@ -9,8 +11,7 @@

# Update sources

- Delete all examples
- `node index.js`
- `npm run create-examples`
- Commit changes
- `git apply --reject changes.patch`
- Fix conflicts
Expand Down
83 changes: 52 additions & 31 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/examples-testing/examples/css2d_label.ts b/examples-testing/examples/css2d_label.ts
index cf61d1e0..693b1e2b 100644
index cf61d1e..693b1e2 100644
--- a/examples-testing/examples/css2d_label.ts
+++ b/examples-testing/examples/css2d_label.ts
@@ -7,7 +7,7 @@ import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
Expand Down Expand Up @@ -39,7 +39,7 @@ index cf61d1e0..693b1e2b 100644
scene.add(moon);

diff --git a/examples-testing/examples/css3d_molecules.ts b/examples-testing/examples/css3d_molecules.ts
index 53847260..f08bb34a 100644
index 5384726..f08bb34 100644
--- a/examples-testing/examples/css3d_molecules.ts
+++ b/examples-testing/examples/css3d_molecules.ts
@@ -5,11 +5,11 @@ import { PDBLoader } from 'three/addons/loaders/PDBLoader.js';
Expand Down Expand Up @@ -155,7 +155,7 @@ index 53847260..f08bb34a 100644
const atom = document.createElement('img');
atom.src = colorSprite;
diff --git a/examples-testing/examples/css3d_orthographic.ts b/examples-testing/examples/css3d_orthographic.ts
index 4aabbed0..5488635e 100644
index 4aabbed..5488635 100644
--- a/examples-testing/examples/css3d_orthographic.ts
+++ b/examples-testing/examples/css3d_orthographic.ts
@@ -3,10 +3,11 @@ import * as THREE from 'three';
Expand Down Expand Up @@ -287,7 +287,7 @@ index 4aabbed0..5488635e 100644
camera.setViewOffset(
fullWidth || window.innerWidth,
diff --git a/examples-testing/examples/css3d_periodictable.ts b/examples-testing/examples/css3d_periodictable.ts
index e3a33f79..516df464 100644
index e3a33f7..516df46 100644
--- a/examples-testing/examples/css3d_periodictable.ts
+++ b/examples-testing/examples/css3d_periodictable.ts
@@ -597,11 +597,16 @@ const table = [
Expand Down Expand Up @@ -392,7 +392,7 @@ index e3a33f79..516df464 100644
.onUpdate(render)
.start();
diff --git a/examples-testing/examples/css3d_sandbox.ts b/examples-testing/examples/css3d_sandbox.ts
index 1088b84b..b910c1f0 100644
index 1088b84..b910c1f 100644
--- a/examples-testing/examples/css3d_sandbox.ts
+++ b/examples-testing/examples/css3d_sandbox.ts
@@ -2,13 +2,13 @@ import * as THREE from 'three';
Expand Down Expand Up @@ -524,7 +524,7 @@ index 1088b84b..b910c1f0 100644
camera.setViewOffset(
fullWidth || window.innerWidth,
diff --git a/examples-testing/examples/css3d_sprites.ts b/examples-testing/examples/css3d_sprites.ts
index dfe24e79..93f2c07b 100644
index dfe24e7..93f2c07 100644
--- a/examples-testing/examples/css3d_sprites.ts
+++ b/examples-testing/examples/css3d_sprites.ts
@@ -4,12 +4,12 @@ import TWEEN from 'three/addons/libs/tween.module.js';
Expand Down Expand Up @@ -572,7 +572,7 @@ index dfe24e79..93f2c07b 100644
.onComplete(transition)
.start();
diff --git a/examples-testing/examples/css3d_youtube.ts b/examples-testing/examples/css3d_youtube.ts
index 62652f87..3dcc2f12 100644
index 62652f8..3dcc2f1 100644
--- a/examples-testing/examples/css3d_youtube.ts
+++ b/examples-testing/examples/css3d_youtube.ts
@@ -3,10 +3,10 @@ import * as THREE from 'three';
Expand Down Expand Up @@ -623,7 +623,7 @@ index 62652f87..3dcc2f12 100644

controls.addEventListener('start', function () {
diff --git a/examples-testing/examples/games_fps.ts b/examples-testing/examples/games_fps.ts
index 49dd6f39..911a1493 100644
index 49dd6f3..911a149 100644
--- a/examples-testing/examples/games_fps.ts
+++ b/examples-testing/examples/games_fps.ts
@@ -39,7 +39,7 @@ directionalLight.shadow.radius = 4;
Expand Down Expand Up @@ -734,7 +734,7 @@ index 49dd6f39..911a1493 100644
});

diff --git a/examples-testing/examples/misc_animation_groups.ts b/examples-testing/examples/misc_animation_groups.ts
index 19d263f4..f8d0bed3 100644
index 19d263f..f8d0bed 100644
--- a/examples-testing/examples/misc_animation_groups.ts
+++ b/examples-testing/examples/misc_animation_groups.ts
@@ -2,8 +2,8 @@ import * as THREE from 'three';
Expand All @@ -749,7 +749,7 @@ index 19d263f4..f8d0bed3 100644
init();
animate();
diff --git a/examples-testing/examples/misc_animation_keys.ts b/examples-testing/examples/misc_animation_keys.ts
index 4a808987..d2613d02 100644
index 4a80898..d2613d0 100644
--- a/examples-testing/examples/misc_animation_keys.ts
+++ b/examples-testing/examples/misc_animation_keys.ts
@@ -2,8 +2,8 @@ import * as THREE from 'three';
Expand All @@ -776,7 +776,7 @@ index 4a808987..d2613d02 100644
scene.add(mesh);

diff --git a/examples-testing/examples/misc_boxselection.ts b/examples-testing/examples/misc_boxselection.ts
index a78c71b3..44337ff5 100644
index a78c71b..44337ff 100644
--- a/examples-testing/examples/misc_boxselection.ts
+++ b/examples-testing/examples/misc_boxselection.ts
@@ -5,73 +5,70 @@ import Stats from 'three/addons/libs/stats.module.js';
Expand Down Expand Up @@ -933,7 +933,7 @@ index a78c71b3..44337ff5 100644
}
});
diff --git a/examples-testing/examples/misc_controls_arcball.ts b/examples-testing/examples/misc_controls_arcball.ts
index f7ea233d..64a2143a 100644
index f7ea233..64a2143 100644
--- a/examples-testing/examples/misc_controls_arcball.ts
+++ b/examples-testing/examples/misc_controls_arcball.ts
@@ -12,8 +12,12 @@ const cameraType = { type: 'Perspective' };
Expand Down Expand Up @@ -999,7 +999,7 @@ index f7ea233d..64a2143a 100644
camera = makeOrthographicCamera();
camera.position.set(0, 0, orthographicDistance);
diff --git a/examples-testing/examples/misc_controls_drag.ts b/examples-testing/examples/misc_controls_drag.ts
index da4bd243..ec63df35 100644
index da4bd24..ec63df3 100644
--- a/examples-testing/examples/misc_controls_drag.ts
+++ b/examples-testing/examples/misc_controls_drag.ts
@@ -2,12 +2,12 @@ import * as THREE from 'three';
Expand Down Expand Up @@ -1051,7 +1051,7 @@ index da4bd243..ec63df35 100644
}

diff --git a/examples-testing/examples/misc_controls_fly.ts b/examples-testing/examples/misc_controls_fly.ts
index 2dd77ec7..7c184f44 100644
index 2dd77ec..7c184f4 100644
--- a/examples-testing/examples/misc_controls_fly.ts
+++ b/examples-testing/examples/misc_controls_fly.ts
@@ -20,11 +20,15 @@ const MARGIN = 0;
Expand Down Expand Up @@ -1102,7 +1102,7 @@ index 2dd77ec7..7c184f44 100644
meshMoon = new THREE.Mesh(geometry, materialMoon);
meshMoon.position.set(radius * 5, 0, 0);
diff --git a/examples-testing/examples/misc_controls_map.ts b/examples-testing/examples/misc_controls_map.ts
index 35e03d2c..698e57ab 100644
index 35e03d2..698e57a 100644
--- a/examples-testing/examples/misc_controls_map.ts
+++ b/examples-testing/examples/misc_controls_map.ts
@@ -4,7 +4,7 @@ import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
Expand All @@ -1127,7 +1127,7 @@ index 35e03d2c..698e57ab 100644
for (let i = 0; i < 500; i++) {
const mesh = new THREE.Mesh(geometry, material);
diff --git a/examples-testing/examples/misc_controls_orbit.ts b/examples-testing/examples/misc_controls_orbit.ts
index 28bc3c01..a13dc532 100644
index 28bc3c0..a13dc53 100644
--- a/examples-testing/examples/misc_controls_orbit.ts
+++ b/examples-testing/examples/misc_controls_orbit.ts
@@ -2,7 +2,7 @@ import * as THREE from 'three';
Expand All @@ -1152,7 +1152,7 @@ index 28bc3c01..a13dc532 100644
for (let i = 0; i < 500; i++) {
const mesh = new THREE.Mesh(geometry, material);
diff --git a/examples-testing/examples/misc_controls_pointerlock.ts b/examples-testing/examples/misc_controls_pointerlock.ts
index d29ffaff..7859eadb 100644
index d29ffaf..7859ead 100644
--- a/examples-testing/examples/misc_controls_pointerlock.ts
+++ b/examples-testing/examples/misc_controls_pointerlock.ts
@@ -2,11 +2,11 @@ import * as THREE from 'three';
Expand Down Expand Up @@ -1222,7 +1222,7 @@ index d29ffaff..7859eadb 100644

const box = new THREE.Mesh(boxGeometry, boxMaterial);
diff --git a/examples-testing/examples/misc_controls_trackball.ts b/examples-testing/examples/misc_controls_trackball.ts
index 19c42c6a..1b7f21ad 100644
index 19c42c6..1b7f21a 100644
--- a/examples-testing/examples/misc_controls_trackball.ts
+++ b/examples-testing/examples/misc_controls_trackball.ts
@@ -5,7 +5,12 @@ import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
Expand Down Expand Up @@ -1270,7 +1270,7 @@ index 19c42c6a..1b7f21ad 100644

controls.rotateSpeed = 1.0;
diff --git a/examples-testing/examples/misc_controls_transform.ts b/examples-testing/examples/misc_controls_transform.ts
index aa4de6f3..7c08981b 100644
index aa4de6f..7c08981 100644
--- a/examples-testing/examples/misc_controls_transform.ts
+++ b/examples-testing/examples/misc_controls_transform.ts
@@ -3,8 +3,8 @@ import * as THREE from 'three';
Expand Down Expand Up @@ -1308,7 +1308,7 @@ index aa4de6f3..7c08981b 100644

orbit.object = currentCamera;
diff --git a/examples-testing/examples/misc_exporter_draco.ts b/examples-testing/examples/misc_exporter_draco.ts
index ce1e6967..f8b4b868 100644
index ce1e696..f8b4b86 100644
--- a/examples-testing/examples/misc_exporter_draco.ts
+++ b/examples-testing/examples/misc_exporter_draco.ts
@@ -4,7 +4,11 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down Expand Up @@ -1340,7 +1340,7 @@ index ce1e6967..f8b4b868 100644
save(new Blob([buffer], { type: 'application/octet-stream' }), filename);
}
diff --git a/examples-testing/examples/misc_exporter_gltf.ts b/examples-testing/examples/misc_exporter_gltf.ts
index c9d94333..c57b22f0 100644
index c9d9433..c57b22f 100644
--- a/examples-testing/examples/misc_exporter_gltf.ts
+++ b/examples-testing/examples/misc_exporter_gltf.ts
@@ -6,7 +6,7 @@ import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
Expand Down Expand Up @@ -1394,7 +1394,7 @@ index c9d94333..c57b22f0 100644
const params = {
trs: false,
diff --git a/examples-testing/examples/misc_exporter_obj.ts b/examples-testing/examples/misc_exporter_obj.ts
index 02ad9072..efb71b1d 100644
index 02ad907..efb71b1 100644
--- a/examples-testing/examples/misc_exporter_obj.ts
+++ b/examples-testing/examples/misc_exporter_obj.ts
@@ -4,7 +4,7 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down Expand Up @@ -1439,7 +1439,7 @@ index 02ad9072..efb71b1d 100644
}

diff --git a/examples-testing/examples/misc_exporter_ply.ts b/examples-testing/examples/misc_exporter_ply.ts
index b6a334dd..a0e6691a 100644
index b6a334d..a0e6691 100644
--- a/examples-testing/examples/misc_exporter_ply.ts
+++ b/examples-testing/examples/misc_exporter_ply.ts
@@ -4,7 +4,11 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down Expand Up @@ -1476,7 +1476,7 @@ index b6a334dd..a0e6691a 100644
save(new Blob([buffer], { type: 'application/octet-stream' }), filename);
}
diff --git a/examples-testing/examples/misc_exporter_stl.ts b/examples-testing/examples/misc_exporter_stl.ts
index 673bad13..71e65414 100644
index 673bad1..71e6541 100644
--- a/examples-testing/examples/misc_exporter_stl.ts
+++ b/examples-testing/examples/misc_exporter_stl.ts
@@ -4,7 +4,11 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down Expand Up @@ -1513,7 +1513,7 @@ index 673bad13..71e65414 100644
save(new Blob([buffer], { type: 'application/octet-stream' }), filename);
}
diff --git a/examples-testing/examples/misc_exporter_usdz.ts b/examples-testing/examples/misc_exporter_usdz.ts
index 9117411b..e6c6e854 100644
index 9117411..e6c6e85 100644
--- a/examples-testing/examples/misc_exporter_usdz.ts
+++ b/examples-testing/examples/misc_exporter_usdz.ts
@@ -6,7 +6,7 @@ import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
Expand Down Expand Up @@ -1544,7 +1544,7 @@ index 9117411b..e6c6e854 100644
canvas.width / 2,
canvas.height / 2,
diff --git a/examples-testing/examples/misc_lookat.ts b/examples-testing/examples/misc_lookat.ts
index f6241b9e..93e83400 100644
index f6241b9..93e8340 100644
--- a/examples-testing/examples/misc_lookat.ts
+++ b/examples-testing/examples/misc_lookat.ts
@@ -2,9 +2,9 @@ import * as THREE from 'three';
Expand All @@ -1569,7 +1569,7 @@ index f6241b9e..93e83400 100644
mouseY = (event.clientY - windowHalfY) * 10;
}
diff --git a/examples-testing/examples/misc_uv_tests.ts b/examples-testing/examples/misc_uv_tests.ts
index 4f782d45..0759cfca 100644
index 4f782d4..0759cfc 100644
--- a/examples-testing/examples/misc_uv_tests.ts
+++ b/examples-testing/examples/misc_uv_tests.ts
@@ -7,7 +7,7 @@ import { UVsDebug } from 'three/addons/utils/UVsDebug.js';
Expand All @@ -1581,8 +1581,29 @@ index 4f782d45..0759cfca 100644
const d = document.createElement('div');

d.innerHTML = '<h3>' + name + '</h3>';
diff --git a/examples-testing/examples/physics_ammo_instancing.ts b/examples-testing/examples/physics_ammo_instancing.ts
index eb33424..aed0936 100644
--- a/examples-testing/examples/physics_ammo_instancing.ts
+++ b/examples-testing/examples/physics_ammo_instancing.ts
@@ -1,12 +1,12 @@
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
-import { AmmoPhysics } from 'three/addons/physics/AmmoPhysics.js';
+import { AmmoPhysics, AmmoPhysicsObject } from 'three/addons/physics/AmmoPhysics.js';
import Stats from 'three/addons/libs/stats.module.js';

-let camera, scene, renderer, stats;
-let physics, position;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer, stats: Stats;
+let physics: AmmoPhysicsObject, position: THREE.Vector3;

-let boxes, spheres;
+let boxes: THREE.InstancedMesh, spheres: THREE.InstancedMesh;

init();

diff --git a/examples-testing/examples/physics_rapier_instancing.ts b/examples-testing/examples/physics_rapier_instancing.ts
index 8f1bdda2..67d3517f 100644
index 8f1bdda..67d3517 100644
--- a/examples-testing/examples/physics_rapier_instancing.ts
+++ b/examples-testing/examples/physics_rapier_instancing.ts
@@ -1,12 +1,12 @@
Expand All @@ -1603,7 +1624,7 @@ index 8f1bdda2..67d3517f 100644
init();

diff --git a/examples-testing/examples/svg_lines.ts b/examples-testing/examples/svg_lines.ts
index 99b74c40..65aaf28d 100644
index 99b74c4..65aaf28 100644
--- a/examples-testing/examples/svg_lines.ts
+++ b/examples-testing/examples/svg_lines.ts
@@ -4,7 +4,7 @@ import { SVGRenderer } from 'three/addons/renderers/SVGRenderer.js';
Expand All @@ -1616,7 +1637,7 @@ index 99b74c40..65aaf28d 100644
init();
animate();
diff --git a/examples-testing/examples/svg_sandbox.ts b/examples-testing/examples/svg_sandbox.ts
index e6be8386..faea9a7a 100644
index e6be838..faea9a7 100644
--- a/examples-testing/examples/svg_sandbox.ts
+++ b/examples-testing/examples/svg_sandbox.ts
@@ -6,9 +6,9 @@ import { SVGRenderer, SVGObject } from 'three/addons/renderers/SVGRenderer.js';
Expand Down Expand Up @@ -1701,7 +1722,7 @@ index e6be8386..faea9a7a 100644
node.appendChild(doc.documentElement);

diff --git a/examples-testing/examples/webaudio_orientation.ts b/examples-testing/examples/webaudio_orientation.ts
index 8a74c418..7258ed10 100644
index 8a74c41..7258ed1 100644
--- a/examples-testing/examples/webaudio_orientation.ts
+++ b/examples-testing/examples/webaudio_orientation.ts
@@ -4,16 +4,16 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down
2 changes: 1 addition & 1 deletion examples-testing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const files = {
physics: [
// 'physics_ammo_break',
// 'physics_ammo_cloth',
// 'physics_ammo_instancing',
'physics_ammo_instancing',
// 'physics_ammo_rope',
// 'physics_ammo_terrain',
// 'physics_ammo_volume',
Expand Down
9 changes: 5 additions & 4 deletions types/three/examples/jsm/physics/AmmoPhysics.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Mesh, Vector3 } from '../../../src/Three';

export class AmmoPhysics {
constructor();
addMesh(mesh: Mesh, mass: number): void;
setMeshPosition(mesh: Mesh, position: Vector3, index: number): void;
export interface AmmoPhysicsObject {
addMesh: (mesh: Mesh, mass?: number) => void;
setMeshPosition: (mesh: Mesh, position: Vector3, index?: number) => void;
}

export function AmmoPhysics(): Promise<AmmoPhysicsObject>;