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
22 changes: 2 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,8 @@ jobs:
- name: Install dependencies
run: npm ci

- name: === Build testing ===
run: npm run build

- name: === Rebranding compatibility testing ===
run: npm run test-rebranding

- name: === Migration tooling testing ===
run: npm run test-migrate

- name: === Lint testing ===
run: npm run lint

- name: === Unit testing ===
run: npm run test-unit

- name: === Unit addons testing ===
run: npm run test-unit-addons

- name: === Examples ready for release ===
run: npm run test-e2e-cov
- name: === Repository verification ===
run: npm test

node-26-parity:
name: Node 26 build & entrypoint parity
Expand Down
35 changes: 35 additions & 0 deletions docs/pages/JoltPhysics.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,41 @@ <h3 class="name name-method" id="setMeshPosition" translate="no">.<a href="#setM
</tbody>
</table>
</div>
<h3 class="name name-method" id="setMeshVelocity" translate="no">.<a href="#setMeshVelocity">setMeshVelocity</a><span class="signature">( mesh : <span class="param-type"><a href="Mesh.html">Mesh</a></span>, velocity : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, index : <span class="param-type">number</span> )</span> </h3>
<div class="method">
<div class="description">
<p>Sets the linear velocity of the given mesh which is part of the physics simulation.</p>
</div>
<table class="params">
<tbody>
<tr>
<td class="name">
<strong translate="no">mesh</strong>
</td>
<td class="description last">
<p>The mesh to update the velocity for.</p>
</td>
</tr>
<tr>
<td class="name">
<strong translate="no">velocity</strong>
</td>
<td class="description last">
<p>The new linear velocity.</p>
</td>
</tr>
<tr>
<td class="name">
<strong translate="no">index</strong>
</td>
<td class="description last">
<p>If the mesh is instanced, the index represents the instanced ID.</p>
<p>Default is <code>0</code>.</p>
</td>
</tr>
</tbody>
</table>
</div>
<h2 class="subsection-title">Source</h2>
<p>
<a href="../../examples/jsm/physics/JoltPhysics.js" translate="no">examples/jsm/physics/JoltPhysics.js</a>
Expand Down
18 changes: 18 additions & 0 deletions docs/pages/JoltPhysics.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ If the mesh is instanced, the index represents the instanced ID.

Default is `0`.

### .setMeshVelocity( mesh : Mesh, velocity : Vector3, index : number )

Sets the linear velocity of the given mesh which is part of the physics simulation.

**mesh**

The mesh to update the velocity for.

**velocity**

The new linear velocity.

**index**

If the mesh is instanced, the index represents the instanced ID.

Default is `0`.

## Source

[examples/jsm/physics/JoltPhysics.js](../../examples/jsm/physics/JoltPhysics.js)
4 changes: 4 additions & 0 deletions docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -19054,6 +19054,10 @@
"title": "JoltPhysics#setMeshPosition",
"kind": "function"
},
{
"title": "JoltPhysics#setMeshVelocity",
"kind": "function"
},
{
"title": "KMZLoader",
"kind": "class"
Expand Down
2 changes: 1 addition & 1 deletion editor/js/Script.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ function Script( editor ) {
const url = new URL( '../build/4.core.js', document.baseURI ).href;
const source = await ( await fetch( url ) ).text();

server.server.defs.push( buildFourDefs( source ) );
server.server.defs.push( buildFourDefs( source ) );
server.server.reset();

} catch ( error ) {
Expand Down
2 changes: 2 additions & 0 deletions editor/js/libs/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global FOUR */

const APP = {

Player: function () {
Expand Down
2 changes: 2 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default [
'**/vendor/**',
'**/fuse/**',
'**/template/static/**',
'manual/examples/resources/webgl-debug-helper.js',
'test/treeshake/*.bundle*.js',
]
},

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/misc/RollerCoaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class RollerCoasterGeometry extends BufferGeometry {

let headingChange = Math.atan2( sample2.x, sample2.z ) - Math.atan2( sample1.x, sample1.z );
if ( headingChange > Math.PI ) headingChange -= Math.PI * 2;
if ( headingChange < -Math.PI ) headingChange += Math.PI * 2;
if ( headingChange < - Math.PI ) headingChange += Math.PI * 2;

quaternion.premultiply( rollQuaternion.setFromAxisAngle( forward, - Math.atan( headingChange * 8 ) * 0.5 ) );

Expand Down Expand Up @@ -398,7 +398,7 @@ class RollerCoasterLiftersGeometry extends BufferGeometry {

let headingChange = Math.atan2( sample2.x, sample2.z ) - Math.atan2( sample1.x, sample1.z );
if ( headingChange > Math.PI ) headingChange -= Math.PI * 2;
if ( headingChange < -Math.PI ) headingChange += Math.PI * 2;
if ( headingChange < - Math.PI ) headingChange += Math.PI * 2;

bankedQuaternion.copy( quaternion );
rollQuaternion.setFromAxisAngle( tangent, - Math.atan( headingChange * 8 ) * 0.5 );
Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/objects/Sky.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
* sky.scale.setScalar( 10000 );
* scene.add( sky );
* ```
*
*
* It can be useful to hide the sun disc when generating an environment map to avoid artifacts
*
*
* ```js
* // disable before rendering environment map
* sky.material.uniforms.showSunDisc.value = false;
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/objects/SkyMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Fn, float, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix,
* ```
*
* It can be useful to hide the sun disc when generating an environment map to avoid artifacts
*
*
* ```js
* // disable before rendering environment map
* sky.showSunDisc.value = false;
Expand Down
66 changes: 44 additions & 22 deletions examples/jsm/physics/JoltPhysics.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ async function JoltPhysics() {
? createInstancedBody( mesh, mass, restitution, shape )
: createBody( mesh.position, mesh.quaternion, mass, restitution, shape );

meshMap.set( mesh, body );

if ( mass > 0 ) {

meshes.push( mesh );
meshMap.set( mesh, body );

}

Expand Down Expand Up @@ -178,45 +179,58 @@ async function JoltPhysics() {

}

function setMeshPosition( mesh, position, index = 0 ) {
function getBody( mesh, index ) {

if ( mesh.isInstancedMesh ) {
let body = meshMap.get( mesh );

const bodies = meshMap.get( mesh );
if ( body === undefined ) {

const body = bodies[ index ];
throw new Error( 'JoltPhysics: Mesh has not been added to the physics simulation.' );

bodyInterface.RemoveBody( body.GetID() );
bodyInterface.DestroyBody( body.GetID() );
}

const physics = mesh.userData.physics;
if ( mesh.isInstancedMesh ) {

const shape = body.GetShape();
const body2 = createBody( position, { x: 0, y: 0, z: 0, w: 1 }, physics.mass, physics.restitution, shape );
body = body[ index ];

bodies[ index ] = body2;
if ( body === undefined ) {

} else {
throw new RangeError( `JoltPhysics: Instanced mesh index ${index} is out of range.` );

// TODO: Implement this
}

}

return body;

}

function setMeshVelocity( mesh, velocity, index = 0 ) {
function setMeshPosition( mesh, position, index = 0 ) {

/*
let body = meshMap.get( mesh );
const body = getBody( mesh, index );
const bodyID = body.GetID();
const nextPosition = new Jolt.RVec3( position.x, position.y, position.z );
const zeroVelocity = new Jolt.Vec3( 0, 0, 0 );

if ( mesh.isInstancedMesh ) {
bodyInterface.SetLinearVelocity( bodyID, zeroVelocity );
bodyInterface.SetAngularVelocity( bodyID, zeroVelocity );
bodyInterface.SetPosition( bodyID, nextPosition, Jolt.EActivation_Activate );

body = body[ index ];
Jolt.destroy( nextPosition );
Jolt.destroy( zeroVelocity );

}
}

function setMeshVelocity( mesh, velocity, index = 0 ) {

const body = getBody( mesh, index );
const bodyID = body.GetID();
const nextVelocity = new Jolt.Vec3( velocity.x, velocity.y, velocity.z );

body.setLinvel( velocity );
*/
bodyInterface.SetLinearVelocity( bodyID, nextVelocity );
bodyInterface.ActivateBody( bodyID );

Jolt.destroy( nextVelocity );

}

Expand Down Expand Up @@ -325,7 +339,15 @@ async function JoltPhysics() {
*/
setMeshPosition: setMeshPosition,

// NOOP
/**
* Sets the linear velocity of the given mesh which is part of the physics simulation.
*
* @method
* @name JoltPhysics#setMeshVelocity
* @param {Mesh} mesh The mesh to update the velocity for.
* @param {Vector3} velocity - The new linear velocity.
* @param {number} [index=0] - If the mesh is instanced, the index represents the instanced ID.
*/
setMeshVelocity: setMeshVelocity
};

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/RetroPassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class RetroPassNode extends PassNode {

let finalUV;

if ( texture.isCubeTextureNode ) {
if ( texture.isCubeTextureNode ) {

finalUV = reflectVector;

Expand Down
2 changes: 1 addition & 1 deletion examples/physics_ammo_break.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

Ammo().then( function ( AmmoLib ) {

Ammo = AmmoLib;
globalThis.Ammo = AmmoLib;

init();

Expand Down
2 changes: 1 addition & 1 deletion examples/physics_ammo_cloth.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

Ammo().then( function ( AmmoLib ) {

Ammo = AmmoLib;
globalThis.Ammo = AmmoLib;

init();

Expand Down
2 changes: 1 addition & 1 deletion examples/physics_ammo_rope.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

Ammo().then( function ( AmmoLib ) {

Ammo = AmmoLib;
globalThis.Ammo = AmmoLib;

init();

Expand Down
2 changes: 1 addition & 1 deletion examples/physics_ammo_terrain.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

Ammo().then( function ( AmmoLib ) {

Ammo = AmmoLib;
globalThis.Ammo = AmmoLib;

init();

Expand Down
2 changes: 1 addition & 1 deletion examples/physics_ammo_volume.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

Ammo().then( function ( AmmoLib ) {

Ammo = AmmoLib;
globalThis.Ammo = AmmoLib;

init();

Expand Down
1 change: 1 addition & 0 deletions examples/webgl_lines_fat.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
} else {

widthController.name( 'width (pixels)' ).min( 1 ).max( 10 ).setValue( 10 );

}

} );
Expand Down
2 changes: 2 additions & 0 deletions examples/webgl_materials_texture_html.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
import { RoomEnvironment } from '@tnb1j/4js/addons/environments/RoomEnvironment.js';
import { InteractionManager } from '@tnb1j/4js/addons/interaction/InteractionManager.js';

const info = document.getElementById( 'info' );

if ( ! ( 'requestPaint' in HTMLCanvasElement.prototype ) ) {

installHtmlInCanvasPolyfill();
Expand Down
Loading