-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ boids: add spawn/destroy buttons, use spawn pattern
- Loading branch information
Showing
8 changed files
with
69 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,8 @@ | ||
import * as THREE from 'three'; | ||
import { InstancedMesh } from '../traits/instanced-mesh'; | ||
import { World } from 'koota'; | ||
import { Position } from '../traits'; | ||
|
||
const dummy = new THREE.Object3D(); | ||
import { Mesh, Position } from '../traits'; | ||
|
||
export const syncThreeObjects = ({ world }: { world: World }) => { | ||
const instanceEntity = world.queryFirst(InstancedMesh); | ||
if (instanceEntity === undefined) return; | ||
|
||
const instancedMesh = instanceEntity.get(InstancedMesh)!.object; | ||
|
||
world.query(Position).updateEach(([position], entity) => { | ||
dummy.position.copy(position); | ||
dummy.scale.set(0.5, 0.5, 0.5); | ||
dummy.updateMatrix(); | ||
instancedMesh.setMatrixAt(entity.id(), dummy.matrix); | ||
world.query(Position, Mesh).updateEach(([position, mesh]) => { | ||
mesh.position.copy(position); | ||
}); | ||
|
||
instancedMesh.instanceMatrix.needsUpdate = true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import * as THREE from 'three'; | ||
import { trait } from 'koota'; | ||
|
||
export const Mesh = trait(() => new THREE.Mesh()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters