Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
diarmidmackenzie committed Jul 25, 2024
2 parents 2be798c + 67d7bb1 commit 831cde4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/instanced-mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,16 @@ AFRAME.registerComponent('instanced-mesh', {
this.componentOriginalColors = [];

this.meshNodes.forEach((node, index) => {
var instancedMesh = new THREE.InstancedMesh(node.geometry,
node.material,
this.data.capacity);
const instancedMesh = new THREE.InstancedMesh(node.geometry,
node.material,
this.data.capacity);
// mesh doesn't have any members yet
instancedMesh.count = 0

// For each instanced mesh required, we store off both the instanced mesh
// itself. and the transform matrix for the component of the model that
// it represents.

this.instancedMeshes.push(instancedMesh)
this.componentMatrices.push(node.matrixWorld)
this.componentMaterialIndices.push(node.materialIndex)
Expand Down
30 changes: 30 additions & 0 deletions tests/empty-instanced-mesh.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<html>
<head>
<script src="https://aframe.io/releases/1.4.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/c-frame/aframe-extras@c5c5dcf/dist/aframe-extras.min.js"></script>
<script src="../src/instanced-mesh.js"></script>
<script src="./framed-block.js"></script>
<link rel="stylesheet" href="./styles.css">
</head>
<body>
<div class="text-overlay">
<p>Empty instanced mesh.</p>
<p>No objects should be visible, amd draw calls should be zero.</p>
</div>
<a class="code-link"
target="_blank"
href="https://github.com/diarmidmackenzie/instanced-mesh/blob/main/tests/empty-instanced-mesh.html">
view code
</a>
<a-scene stats renderer="colorManagement:true">

<a-entity id="rig" movement-controls>
<a-entity id="camera" camera position="0 1.6 3" look-controls>
</a-entity>
</a-entity>

<a-entity id="mesh1" framed-block="facecolor: white; framecolor: black" instanced-mesh="capacity:500"></a-entity>

</a-scene>

</body>

0 comments on commit 831cde4

Please sign in to comment.