Skip to content

Commit

Permalink
making use of mesh rather than aggregate for global repositioning in …
Browse files Browse the repository at this point in the history
…playground
  • Loading branch information
BarthPaleologue committed Aug 3, 2023
1 parent 50c8ef8 commit ede91f6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/ts/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const aggregates = [sphereAggregate, boxAggregate, capsuleAggregate, spaceship.g
for(const aggregate of aggregates) {
aggregate.body.disablePreStep = false;
}
const meshes = [sphere, box, capsule, spaceship.instanceRoot, newton.transform.node];

const fallingAggregates = [sphereAggregate, boxAggregate, capsuleAggregate, spaceship.getAggregate()];
//viewer.showBody(spaceship.getAggregate().body);
Expand All @@ -117,11 +118,7 @@ const gravity = -9.81;

let clockSeconds = 0;
function updateScene() {
// move back everything to the origin
const spaceshipPosition = spaceship.getAbsolutePosition();
for(const aggregate of aggregates) {
aggregate.transformNode.position.subtractInPlace(spaceshipPosition);
}


const deltaTime = engine.getDeltaTime() / 1000;
clockSeconds += deltaTime;
Expand All @@ -144,6 +141,13 @@ function updateScene() {
newton.updateLOD(camera.globalPosition);
newton.material.update(camera.globalPosition, [light.getAbsolutePosition()]);
Assets.ChunkForge.update();

// move back everything to the origin
const spaceshipPosition = spaceship.getAbsolutePosition();

for(const mesh of meshes) {
mesh.position.subtractInPlace(spaceshipPosition);
}
}

scene.executeWhenReady(() => {
Expand Down

0 comments on commit ede91f6

Please sign in to comment.